Part Number Hot Search : 
C1312 882212 00ETTS L24C32 2SC2459 10481 B3N1T AS5043TR
Product Description
Full Text Search
 

To Download PIC24F08KM102-ISO Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2013 microchip technology inc. ds30003030b-page 1 pic24fv16km204 family analog peripheral features up to two 8-bit digital-to-analog converters (dacs): - soft reset disable function allows dac to retain its output value through non-v dd resets - support for idle mode - support for left and right justified input data two operational amplifiers (op amps): - differential inputs - selectable power/speed levels: - low power/low speed - high power/high speed up to 22-channel, 10/12-bit analog-to-digital converter: - 100k samples/second at 12-bit conversion rate (single sample-and-hold) - auto-scan with threshold detect - can operate during sleep - dedicated band gap reference and temperature sensor input up to three rail-to-rail analog comparators: - programmable reference voltage for comparators - band gap reference input - flexible input multiplexing - low-power or high-speed selection options charge time measurement unit (ctmu): - capacitive measurement, up to 22 channels - time measurement down to 200 ps resolution - up to 16 external trigger pairs internal temperature sensor with dedicated a/d converter input high-performance risc cpu modified harvard architecture operating speed: - dc C 32 mhz clock input - 16 mips at 32 mhz clock input 8 mhz internal oscillator: - 4x pll option - multiple clock divide options - fast start-up 17-bit x 17-bit single-cycle hardware fractional/integer multiplier 32-bit by 16-bit hardware divider 16 x 16-bit working register array c compiler optimized instruction set architecture 24-bit-wide instructions 16-bit-wide data path linear program memory addressing, up to 6 mbytes linear data memory addressing, up to 64 kbytes two address generation units (agus) for separate read and write addressing of data memory multiple/single capture compare peripheral (mccp/sccp) features 16 or 32-bit time base 16 or 32-bit capture: - 4-deep capture buffer 16 or 32-bit compare: - single edge compare modes - dual edge compare/pwm modes - center-aligned compare mode - variable frequency pulse mode single output steerable mode (mccp only) brush dc forward and reverse modes (mccp only) half-bridge with dead-time delay (mccp only) push-pull pwm mode (mccp only) auto-shutdown with programmable source and shutdown state programmable output polarity general purpose, 16-bit flash microcontrollers with xlp technology data sheet downloaded from: http:///
pic24fv16km204 family ds30003030b-page 2 ? 2013 microchip technology inc. device pins memory voltage range (v) peripherals icd brkpt flash program (bytes) sram (bytes) ee data (bytes) 16-bit timer 16-bit mccp/sccp mssp uart 12-bit a/d channels 8-bit dac op amp comparators ctmu rtcc clc 5v devices pic24fv16km204 44 16k 2k 512 2.0-5.5 1 3/2 2 2 22 2 2 3 yes yes 2 3 pic24fv16km202 28 16k 2k 512 2.0-5.5 1 3/2 2 2 19 2 2 3 yes yes 2 3 pic24fv08km204 44 8k 2k 512 2.0-5.5 1 3/2 2 2 22 2 2 3 yes yes 2 3 pic24fv08km202 28 8k 2k 512 2.0-5.5 1 3/2 2 2 19 2 2 3 yes yes 2 3 pic24fv16km104 44 16k 1k 512 2.0-5.5 1 1/1 1 1 22 1 yes 1 3 pic24fv16km102 28 16k 1k 512 2.0-5.5 1 1/1 1 1 19 1 yes 1 3 pic24fv08km102 28 8k 1k 512 2.0-5.5 1 1/1 1 1 19 1 yes 1 3 pic24fv08km101 20 8k 1k 512 2.0-5.5 1 1/1 1 1 16 1 yes 1 3 3v devices pic24f16km204 44 16k 2k 512 1.8-3.6 1 3/2 2 2 22 2 2 3 yes yes 2 3 pic24f16km202 28 16k 2k 512 1.8-3.6 1 3/2 2 2 19 2 2 3 yes yes 2 3 pic24f08km204 44 8k 2k 512 1.8-3.6 1 3/2 2 2 22 2 2 3 yes yes 2 3 pic24f08km202 28 8k 2k 512 1.8-3.6 1 3/2 2 2 19 2 2 3 yes yes 2 3 pic24f16km104 44 16k 1k 512 1.8-3.6 1 1/1 1 1 22 1 yes 1 3 pic24f16km102 28 16k 1k 512 1.8-3.6 1 1/1 1 1 19 1 yes 1 3 pic24f08km102 28 8k 1k 512 1.8-3.6 1 1/1 1 1 19 1 yes 1 3 pic24f08km101 20 8k 1k 512 1.8-3.6 1 1/1 1 1 16 1 yes 1 3 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 3 pic24fv16km204 family peripheral features high-current sink/source, 18 ma/18 ma all ports independent ultra low-power, 32 khz timer oscillator up to two master synchronous serial ports (mssps) with spi and i 2 c? modes: in spi mode: - user-configurable sckx and sdox pin outputs - daisy-chaining of spi slave devices in i 2 c mode: - serial clock synchronization (clock stretching) - bus collision detection and will arbitrate accordingly - support for 16-bit read/write interface up to two enhanced addressable uarts: - lin/j2602 bus support (auto-wake-up, auto-baud detect, break character support) - high and low speed (sci) -irda ? mode (hardware encoder/decoder function) two external interrupt pins hardware real-time clock and calendar (rtcc) configurable reference clock output (refo) two configurable logic cells (clc) up to two single output capture/compare/pwm (sccp) modules and up to three multiple output capture/compare/pwm (mccp) modules special microcontroller features wide operating voltage range options: - 1.8v to 3.6v (pic24f devices) - 2.0v to 5.0v (pic24fv devices) selectable power management modes: - idle: cpu shuts down, allowing for significant power reduction - sleep: cpu and peripherals shut down for substantial power reduction and fast wake-up - retention sleep mode: pic24fv devices can enter sleep mode, employing the retention regulator, further reducing power consumption - doze: cpu can run at a lower frequency than peripherals, a user-programmable feature - alternate clock modes allow on-the-fly switching to a lower clock speed for selective power reduction fail-safe clock monitor: - detects clock failure and switches to on-chip, low-power rc oscillator ultra low-power wake-up pin provides an external trigger for wake from sleep 10,000 erase/write cycle endurance flash program memory, typical 100,000 erase/write cycle endurance data eeprom, typical flash and data eeprom data retention: 20 years minimum self-programmable under software control power-on reset (por), power-up timer (pwrt) and oscillator start-up timer (ost) watchdog timer (wdt) with its own on-chip rc oscillator for reliable operation on-chip regulator for 5v operation selectable windowed wdt feature selectable oscillator options including: - 4x phase locked loop (pll) 8 mhz (frc) internal rc oscillator: - hs/ec, high-speed crystal/resonator oscillator or external clock in-circuit serial programming? (icsp?) and in-circuit emulation (ice) C via two pins in-circuit debugging programmable high/low-voltage detect (hlvd) module programmable brown-out reset (bor): - software enable feature - configurable shutdown in sleep - auto-configures power mode and sensitivity based on device operating speed - lpbor available for re-arming of the por downloaded from: http:///
pic24fv16km204 family ds30003030b-page 4 ? 2013 microchip technology inc. pin diagrams pin pin features pic24f08km101 pic24fvkm08km101 1m c l r /v pp /ra5 2 pgec2/cv ref +/v ref +/an0/cn2/ra0 3 pged2/cv ref -/v ref -/an1/cn3/ra1 4 pged1/an2/ctcmp/ulpwu/c1ind/oc2a/cn4/rb0 5 pgec1/an3/c1inc/cted12/cn5/rb1 6 an4/u1rx/tckib/cted13/cn6/rb2 7 osci/clki/an13/c1inb/cn30/ra2 8 osco/clko/an14/c1ina/cn29/ra3 9 pged3/sosci/an15/clcina/cn1/rb4 10 pgec3/sosco/sclki/an16/pwrlclk/clcinb/cn0/ra4 11 an19/u1tx/cted1/int0/cn23/rb7 an19/u1tx/ic1/oc1a/cted1/int0/cn23/rb7 12 an20/scl1/u1cts /oc1b/cted10/cn22/rb8 13 an21/sda1/t1ck/u1rts /u1bclk/ic2/clc1o/cted4/cn21/rb9 14 ic1/oc1a/int2/cn8/ra6 v cap or v ddcore 15 an12/hlvdin/sck1/oc1c/cted2/cn14/rb12 an12/hlvdin/sck1/oc1c/cted2/int2/cn14/rb12 16 an11/sdo1/ocfb/oc1d/ctpls/cn13/rb13 17 cv ref /an10/sdi1/c1out/ocfa/cted5/int1/cn12/rb14 18 an9/refo/ss1 /tckia/cted6/cn11/rb15 19 v ss /av ss 20 v dd /av dd 20-pin pdip/ssop/soic pic24f08km101 ra5ra3 ra0ra1 v dd v ss rb0 rb7 ra4 rb4 rb8 ra2 rb2 rb1 12 3 4 5 6 7 8 9 10 2019 18 17 16 15 14 13 12 11 rb15 rb14 rb13 rb9 ra6 or v ddcore rb12 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 5 pic24fv16km204 family pin diagrams (continued) 20-pin qfn pin pin features pic24f08km101 pic24fv08km101 1 pged1/an2/ctcmp/ulpwu/c1ind/oc2a/cn4/rb0 2 pgec1/an3/c1inc/cted12/cn5/rb1 3 an4/u1rx/tckib/cted13/cn6/rb2 4 osci/clki/an13/c1inb/cn30/ra2 5 osco/clko/an14/c1ina/cn29/ra3 6 pged3/sosci/an15/clcina/cn1/rb4 7 pgec3/sosco/sclki/an16/ pwrlclk/clcinb/cn0/ra4 8 an19/u1tx/cted1/int0/cn23/rb7 an19/u1tx/ic1/oc1a/cted1/int0/cn23/rb7 9 an20/scl1/u1cts /oc1b/cted10/cn22/rb8 10 an21/sda1/t1ck/u1rts /u1bclk/ic2/clc1o/cted4/cn21/rb9 11 ic1/oc1a/int2/cn8/ra6 v cap or v ddcore 12 an12/hlvdin/sck1/oc1c/cted2/cn14/rb12 an12/hlvdin/sck1/oc1c/cted2/int2/cn14/rb12 13 an11/sdo1/ocfb/oc1d/ctpls/cn13/rb13 14 cv ref /an10/sdi1/c1out/ocfa/cted5/int1/cn12/rb14 15 an9/refo/ss1 /tckia/cted6/cn11/rb15 16 v ss /av ss 17 v dd /av dd 18 mclr /v pp /ra5 19 pgec2/cv ref + /v ref +/an0/cn2/ra0 20 pged2/cv ref -/v ref -/an1/cn3/ra1 pic24f08km101 23 15 4 678910 11 12 13 14 15 16 17 18 19 20 rb0rb1 rb2 ra2 ra3 rb7 rb9 ra4 rb4 rb8 ra6 or v ddcore rb12 rb13 rb14 rb15 cv ref - cv ref + ra5 ra0 ra1 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 6 ? 2013 microchip technology inc. pin diagrams (continued) pin pin features pic24fxxkmx02 pic24fvxxkmx02 1m c l r /v pp /ra5 2c v ref +/v ref +/ dac1ref+ /an0/ c3inc /cn2/ra0 3c v ref -/v ref -/an1/cn3/ra1 cv ref -/v ref -/an1/ra1 4 pged1/an2/ctcmp/ulpwu/c1ind/ c2inb / c3ind / u2tx /cn4/rb0 5p g e c 1 / oa1ina / oa2ina /an3/c1inc/ c2ina / u2rx /cted12/cn5/rb1 6 oa1inb / oa2inb /an4/c1inb/ c2ind / sda2 /u1rx/tckib/cted13/cn6/rb2 7 oa1out /an5/c1ina/ c2inc / scl2 /cn7/rb3 8v ss 9 osci/clki/an13/cn30/ra2 10 osco/clko/an14/cn29/ra3 11 sosci/an15/ u2rts / u2bclk /cn1/rb4 12 sosco/sclki/an16/pwrlclk/ u2cts /cn0/ra4 13 v dd 14 pged3/an17/asda1/ sck2 / ic4 /oc1e/clcina/cn27/rb5 15 pgec3/an18/ascl1/ sdo2 / ic5 /oc1f/clcinb/cn24/rb6 16 an19/u1tx/int0/cn23/rb7 an19/u1tx/ c2out / oc1a /int0/cn23/rb7 17 an20/scl1/u1cts /c3out/oc1b/cted10/cn22/rb8 18 an21/sda1/t1ck/u1rts /u1bclk/ic2/ oc4 /clc1o/cted4/cn21/rb9 19 sdi2 /ic1/ oc5 / clc2o /cted3/cn9/ra7 20 c2out /oc1a/cted1/int2/cn8/ra6 v cap or v ddcore 21 pged2/sdi1/ oc3a /oc1c/cted11/cn16/rb10 22 pgec2/sck1/oc2a/cted9/cn15/rb11 23 dac1out /an12/hlvdin/ ss2 / ic3 / oc2b /cted2/cn14/rb12 dac1out /an12/hlvdin/ ss2 / ic3 / oc2b /cted2/int2/cn14/ rb12 24 oa1inc / oa2inc /an11/sdo1/ocfb/ oc3b /oc1d/ctpls/cn13/rb13 25 dac2out /cv ref / oa1ind / oa2ind /an10/ c3inb / rtcc /c1out/ocfa/cted5/int1/cn12/rb14 26 dac2ref+ / oa2out /an9/ c3ina /refo/ss1 /tckia/cted6/cn11/rb15 27 v ss /av ss 28 v dd /av dd 28-pin spdip/ssop/soic pic24f16kmx02 mclr /ra5 v ss ra0ra1 av dd av ss rb0 ra7 ra3 ra2 ra6 or v ddcore rb3 rb2 rb1 12 3 4 5 6 7 8 9 10 2827 26 25 24 23 22 21 20 19 rb15 rb14 rb13 rb10 rb11 rb12 ra4 rb6 rb5 v dd rb7 1112 13 14 1817 16 15 rb8 rb9 rb4 legend: values in red indicate pin function differences between pic24f(v)xxkm202 and pic24f(v)xxkm102 devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 7 pic24fv16km204 family pin diagrams (continued) legend: values in red indicate pin function differences between pic24f(v)xxkm202 and pic24f(v)xxkm102 devices. note 1: exposed pad on underside of device is connected to v ss . 28-pin qfn (1) 10 11 23 6 1 18 19 20 21 22 12 13 14 15 8 7 16 17 23 24 25 26 27 28 9 pic24f16kmx02 5 4 mclr /ra5 v ss v dd ra0 ra1v dd v ss rb0 rb6 ra4 rb4 ra7 ra3 ra2 ra6 or v ddcore rb7 rb9 rb8 rb3 rb2 rb1 rb15 rb14 rb13 rb12 rb10 rb11 rb5 pin pin features pin features pic24fxxkmx02 pic24fvxxkmx02 1 pged1/an2/ctcmp/ulpwu/c1ind/ c2inb / c3ind / u2tx /cn4/rb0 2pgec1/ oa1ina / oa2ina /an3/c1inc/ c2ina / u2rx /cted12/cn5/rb1 3 oa1inb / oa2inb /an4/c1inb/ c2ind / sda2 /u1rx/tckib/cted13/cn6/rb2 4 oa1out /an5/c1ina/ c2inc / scl2 /cn7/rb3 5v ss 6 osci/clki/an13/cn30/ra2 7 osco/clko/an14/cn29/ra3 8 sosci/an15/ u2rts / u2bclk /cn1/rb4 9 sosco/sclki/an16/pwrlclk/ u2cts /cn0/ra4 10 v dd 11 pged3/an17/asda1/ sck2 / ic4 /oc1e/clcina/cn27/rb5 12 pgec3/an18/ascl1/ sdo2 / ic5 /oc1f/clcinb/cn24/rb6 13 an19/u1tx/int0/cn23/rb7 an19/u1tx/ c2out /oc1a/int0/cn23/rb7 14 an20/scl1/u1cts /c3out/oc1b/cted10/cn22/rb8 15 an21/sda1/t1ck/u1rts /u1bclk/ic2/ oc4 /clc1o/cted4/cn21/rb9 16 sdi2 /ic1/ oc5 / clc2o /cted3/cn9/ra7 17 c2out /oc1a/cted1/int2/cn8/ra6 v ddcore /v cap 18 pged2/sdi1/ oc3a /oc1c/cted11/cn16/rb10 19 pgec2/sck1/oc2a/cted9/cn15/rb11 20 dac1out /an12/hlvdin/ ss2 / ic3 / oc2b /cted2/cn14/rb12 dac1out /an12/hlvdin/ss2 / ic3 / oc2b /cted2/int2/cn14/rb12 21 oa1inc / oa2inc /an11/sdo1/ocfb/oc3b/oc1d/ctpls/cn13/rb13 22 dac2out /cv ref / oa1ind / oa2ind /an10/ c3inb / rtcc /c1out/ocfa/cted5/int1/cn12/rb14 23 dac2ref+ / oa2out /an9/ c3ina /refo/ss1 /tckia/cted6/cn11/rb15 24 v ss 25 v dd 26 mclr /v pp /ra5 27 cv ref +/v ref +/ dac1ref+ /an0/ c3inc /cn2/ra0 cv ref +/v ref +/ dac1ref+ /an0/ c3inc /cted1/cn2/ra0 28 cv ref -/v ref -/an1/cn3/ra1 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 8 ? 2013 microchip technology inc. pin diagrams (continued) legend: values in red indicate pin function differences between pic24f(v)xxkm202 and pic24f(v)xxkm102 devices. note 1: exposed pad on underside of device is connected to v ss . pin pin features pic24fxxkmx04 pic24fvxxkmx04 1 an21/sda1/t1ck/u1rts /u1bclk/ic2/ oc4 /clc1o/cted4/cn21/rb9 2 u1rx/ oc2c /cn18/rc6 3 u1tx/ oc2d /cn17/rc7 4 oc2e /cn20/rc8 5 ic4/oc2f/cted7/cn19/rc9 6 ic1/ oc5 / clc2o /cted3/cn9/ra7 7 c2out /oc1a/cted1/int2/cn8/ra6 v cap or v ddcore 8 pged2/sdi1/oc1c/cted11/cn16/rb10 9 pgec2/sck1/oc2a/cted9/cn15/rb11 10 dac1out /an12/hlvdin/ oc2b /cted2/ cn14/rb12 dac1out /an12/hlvdin/ oc2b /cted2/int2/ cn14/rb12 11 oa1inc / oa2inc /an11/sdo1/oc1d/ctpls/cn13/rb13 12 ic5 / oc3a /cn35/ra10 13 ic3 / oc3b /cted8/cn36/ra11 14 dac2out /cv ref / oa1ind / oa2ind /an10/ c3inb / rtcc /c1out/ocfa/cted5/int1/cn12/ rb14 15 dac2ref+ / oa2out /an9/ c3ina /refo/ss1 /tckia/cted6/cn11/rb15 16 av ss 17 av dd 18 mclr /v pp /ra5 19 cv ref +/v ref +/ dac1ref+ /an0/ c3inc /cn2/ ra0 cv ref +/v ref +/ dac1ref+ /an0/ c3inc / cted1/cn2/ra0 20 cv ref -/v ref -/an1/cn3/ra1 21 pged1/an2/ctcmp/ulpwu/c1ind/ c2inb / c3ind / u2tx /cn4/rb0 22 pgec1/ oa1ina / oa2ina /an3/c1inc/ c2ina / u2rx /cted12/cn5//rb1 23 oa1inb / oa2inb /an4/c1inb/ c2ind / sda2 /tckib/cted13/cn6/rb2 24 oa1out /an5/c1ina/ c2inc / scl2 /cn7/rb3 25 an6/cn32/rc0 26 an7/cn31/rc1 27 an8/cn10/rc2 28 v dd 29 v ss 30 osci/clki/an13/cn30/ra2 31 osco/clko/an14/cn29/ra3 32 ocfb/cn33/ra8 33 sosci/an15/ u2rts / u2bclk /cn1/rb4 34 sosco/sclki/an16/pwrlclk/ u2cts /cn0/ra4 35 ss2 /cn34/ra9 36 sdi2 /cn28/rc3 37 sdo2 /cn25/rc4 38 sck2 /cn26/rc5 39 v ss 40 v dd 41 pged3/an17/asda1/oc1 e/clcina/cn27/rb5 42 pgec3/an18/ascl1/oc1f/clcinb/cn24/rb6 43 an19/int0/cn23/rb7 an19/ c2out /oc1a/int0/cn23/rb7 44 an20/scl1/u1cts /c3out/oc1b/cted10/cn22/rb8 1011 23 4 5 6 1 1819 20 21 22 1213 14 15 38 8 7 4443 42 41 40 39 1617 29 30 31 32 3323 24 25 26 27 28 3634 35 9 pic24fxxkmx04 37 rb8rb7 rb6 rb5 v dd v ss rc5rc4 rc3 ra9 ra4 rb4 ra8 ra3 ra2 v ss v dd rc2rc1 rc0 rb3 rb2 rb9 rc6rc7 rc8 rc9 ra7ra6 rb10 rb11 rb12 rb13 rb1 rb0 ra1 ra0 mclr /ra5 av dd av ss rb15 rb14 ra11 ra10 44-pin tqfp/qfn (1) downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 9 pic24fv16km204 family pin diagrams (continued) pin pin features pic24fxxkmx04 pic24fvxxkmx04 1 an21/sda1/t1ck/u1rts /u1bclk/ic2/ oc4 /clc1o/cted4/cn21/rb9 2 u1rx/ oc2c /cn18/rc6 3 u1tx/ oc2d /cn17/rc7 4 oc2/cn20/rc8 5 ic4/oc2f/cted7/cn19/rc9 6 ic1/ oc5 / clc2o /cted3/cn9/ra7 7 c2out /oc1a/cted1/int2/cn8/ra6 v ddcore or v cap 8n/c n/c 9 pged2/sdi1/oc1c/cted11/cn16/rb10 10 pgec2/sck1/oc2a/cted9/cn15/rb11 11 dac1out /an12/hlvdin/ oc2b /cted2/ cn14/rb12 dac1out /an12/hlvdin/ oc2b /cted2/ int2/cn14/rb12 12 oa1inc / oa2inc /an11/sdo1/oc1d/ctpls/cn13/rb13 13 ic5 / oc3a /cn35/ra10 14 ic3 / oc3b /cted8/cn36/ra11 15 dac2out /cv ref / oa1ind / oa2ind /an10/ c3inb / rtcc /c1out/ocfa/cted5/int1/ cn12/rb14 16 dac2ref+ / oa2out /an9/ c3ina /refo/ss1 /tckia/cted6/cn11/rb15 17 v ss /av ss 18 v dd /av dd 19 mclr /v pp /ra5 20 n/c 21 cv ref +/v ref +/ dac1ref +/an0/ c3inc / cn2/ra0 cv ref +/v ref +/ dac1ref +/an0/ c3inc / cted1/cn2/ra0 22 cv ref -/v ref -/an1/cn3/ra1 23 pged1/an2/ctcmp/ulpwu/c1ind/ c2inb / c3ind / u2tx /cn4/rb0 24 pgec1/ oa1ina / oa2ina /an3/c1inc/ c2ina / u2rx /cted12/cn5/rb1 25 oa1inb / oa2inb /an4/c1inb/ c2ind / sda2 /tckib/cted13/cn6/rb2 26 oa1out /an5/c1ina/ c2inc / scl2 /cn7/rb3 27 an6/cn32/rc0 28 an7/cn31/rc1 29 an8/cn10/rc2 30 v dd 31 v ss 32 n/c 33 osci/an13/clki/cn30/ra2 34 osco/clko/an14/cn29/ra3 35 ocfb/cn33/ra8 36 sosci/an15/ u2rts / u2bclk /cn1/rb4 37 sosco/sclki/an16/pwrlclk/ u2cts /cn0/ra4 38 ss2 /cn34/ra9 39 sdi2 /cn28/rc3 40 sdo2 /cn25/rc4 41 sck2 /cn26/rc5 42 v ss 43 v dd 44 n/c 45 pged3/an17/asda1/oc1e/clcina/cn27/rb5 46 pgec3/an18/ascl1/oc1f/clcinb/cn24/rb6 47 an19/int0/cn23/rb7 an19/ c2out /oc1a/int0/cn23/rb7 48 an20/scl1/u1cts /c3out/oc1b/cted10/cn22/rb8 48-pin uqfn (1) r b 8 r b 7 r b 6 r b 5 n / c v d d v s s r c 5 r c 4 r c 3 r a 9 r a 4 4 8 4 7 4 6 4 5 4 4 4 3 4 2 4 1 4 0 3 9 3 8 3 7 rb9 1 36 rb4 rc6 2 35 ra8 rc7 3 34 ra3 rc8 4 33 ra2 rc9 5 32 n/c ra7 6 pic24fxxkmx04 31 v ss ra6 7 30 v dd n/c 8 29 rc2 rb10 9 28 rc1 rb11 10 27 rc0 rb12 11 26 rb3 rb13 12 25 rb2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 r a 1 0 r a 1 1 r b 1 4 r b 1 5 v s s / a v s s v d d / a v d d n / c r a 0 r a 1 r b 0 r b 1 pic24fvxxkmx04 m c l r / r a 5 legend: values in red indicate pin function differences between pic24f(v)xxkm202 and pic24f(v)xxkm102 devices. note 1: exposed pad on underside of device is connected to v ss . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 10 ? 2013 microchip technology inc. table of contents 1.0 device overview ............................................................................ ................................. ........................................................... 13 2.0 guidelines for getting started with 16-bit microcontrollers . ................................................................ ....................................... 29 3.0 cpu ............................................................................................... ......................... ................................................................... 35 4.0 memory organization .......................................... ................................................... ............ ........................................................ 41 5.0 flash program memory.................................................................. ...................................... ...................................................... 67 6.0 data eeprom memory ..................................................................... ..................................... ................................................... 73 7.0 resets .......................................................................................... .............................................................................................. 79 8.0 interrupt controller ................................................................ ........................................ ............................................................. 85 9.0 oscillator configuration ...................................... ......................................................................................................... ............. 121 10.0 power-saving features......................................................... ............................................. ...................................................... 131 11.0 i/o ports ....................................................................................... ........................... ................................................................. 137 12.0 timer1 ......................................................................................... ........................... ................................................................. 141 13.0 capture/compare/pwm/timer modules (mccp and sccp) ............ .............................................................. ........................ 143 14.0 master synchronous serial port (mssp) ................................. ................................................... .. ........................................... 159 15.0 universal asynchronous receiver transmitter (uart) ............................... .......................................... .................................. 173 16.0 real-time clock and calendar (rtcc) ..................................... .................................................. ........................................... 181 17.0 configurable logic cell (clc)........................................ ................................................... ... .................................................... 195 18.0 high/low-voltage detect (hlvd)......................................... ................................................... . ................................................ 207 19.0 12-bit a/d converter with threshold detect ...................................... ........................................... ........................................... 209 20.0 8-bit digital-to-analog converter (dac)......................................... ........................................... ............................................... 229 21.0 dual operational amplifier module...................................... ................................................... . ................................................. 233 22.0 comparator module......................................... ................................................... .............. ........................................................ 235 23.0 comparator voltage reference.................................. ................................................... .......... ................................................. 239 24.0 charge time measurement unit (ctmu) .......................................... .............................................. ........................................ 241 25.0 special features ........................................................................ ................................... ........................................................... 249 26.0 development support............................................ ................................................... ......... ....................................................... 261 27.0 electrical characteristics ....................................................... .......................................... ......................................................... 265 28.0 packaging information............................................. ......................................................... ........................................................ 297 appendix a: revision history.......................................... ................................................... ...... .......................................................... 325 index ................................................. ................................................... ...................... ....................................................................... 327 the microchip web site .................................................................. ....................................... ............................................................ 333 customer change notification service ....................................... ................................................... . ................................................... 333 customer support ............................................... ................................................... ............. ............................................................... 333 product identification system.................................................. ........................................................................................................... 335 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 11 pic24fv16km204 family to our valued customers it is our intention to provide our valued customers with the best documentation possible to ensure successful use of your micro chip products. to this end, we will continue to improve our publications to better suit your needs. our publications will be refined and enhanced as new volumes and updates are introduced. if you have any questions or comments regardi ng this publication, please contact the marketing communications department via e-mail at docerrors@microchip.com . we welcome your feedback. most current data sheet to obtain the most up-to-date version of this data s heet, please register at our worldwide web site at: http://www.microchip.com you can determine the version of a data sheet by examining its literature number found on the bottom outside corner of any page . the last character of the literature number is the versi on number, (e.g., ds30000000a is ve rsion a of document ds30000000). errata an errata sheet, describing minor operational differences fr om the data sheet and recommended workarounds, may exist for curren t devices. as device/documentation issues become known to us, we will publish an errata sheet. the errata will specify the revisi on of silicon and revision of document to which it applies. to determine if an errata sheet exists for a particul ar device, please check with one of the following: microchips worldwide web site; http://www.microchip.com your local microchip sales office (see last page) when contacting a sales office, please spec ify which device, revision of silicon and data sheet (include literature number) you are using. customer notification system register on our web site at www.microchip.com to receive the most current information on all of our products. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 12 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 13 pic24fv16km204 family 1.0 device overview this document contains device-specific information for the following devices: the pic24fv16km204 family introduces many new analog features to the extreme low-power microchip devices. this is a 16-bit microcontroller family with a broad peripheral feature set and enhanced computa- tional performance. this family also offers a new migration option for those high-performance applica- tions which may be outgrowing their 8-bit platforms, but do not require the numerical processing power of a digital signal processor (dsc). 1.1 core features 1.1.1 16-bit architecture central to all pic24f devices is the 16-bit modified harvard architecture, first introduced with microchips dspic ? digital signal controllers. the pic24f cpu core offers a wide range of enhancements, such as: 16-bit data and 24-bit address paths with the ability to move information between data and memory spaces linear addressing of up to 16 mbytes (program space) and 16 kbytes (data) a 16-element working register array with built-in software stack support a 17 x 17 hardware multiplier with support for integer math hardware support for 32-bit by 16-bit division an instruction set that supports multiple address- ing modes and is optimized for high-level languages, such as c operational performance up to 16 mips 1.1.2 power-saving technology all of the devices in the pic24fv16km204 family incor- porate a range of features that can significantly reduce power consumption during operation. key features include: on-the-fly clock switching, to allow the device clock to be changed under software control to the timer1 source or the internal, low-power rc oscillator during operation, allowing users to incorporate power-saving ideas into their software designs. doze mode operation, when timing-sensitive applications, such as serial communications, require the uninterrupted operation of peripherals, the cpu clock speed can be selectively reduced, allowing incremental power savings without missing a beat. instruction-based power-saving modes, to allow the microcontroller to suspend all operations or selectively shut down its core while leaving its peripherals active with a single instruction in software. 1.1.3 oscillator options and features the pic24fv16km204 family offers five different oscil- lator options, allowing users a range of choices in developing application hardware. these include: two crystal modes using crystals or ceramic resonators. two external clock (ec) modes offering the option of a divide-by-2 clock output. two fast internal oscillators (frcs), one with a nominal 8 mhz output and the other with a nominal 500 khz output. these outputs can also be divided under software control to provide clock speed as low as 31 khz or 2 khz. a phase locked loop (pll) frequency multiplier, available to the external oscillator modes and the 8 mhz frc oscillator, which allows clock speeds of up to 32 mhz. a separate internal rc oscillator (lprc) with a fixed 31 khz output, which provides a low-power option for timing-insensitive applications. the internal oscillator block also provides a stable ref- erence source for the fail-safe clock monitor (fscm). this option constantly monitors the main clock source against a reference signal provided by the internal oscillator and enables the controller to switch to the internal oscillator, allowing for continued low-speed operation or a safe application shutdown. pic24fv08km101 pic24f08km101 pic24fv08km102 pic24f08km102 pic24fv16km102 pic24f16km102 pic24fv16km104 pic24f16km104 pic24fv08km202 pic24f08km202 pic24fv08km204 pic24f08km204 pic24fv16km202 pic24f16km202 pic24fv16km204 pic24f16km204 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 14 ? 2013 microchip technology inc. 1.1.4 easy migration the pic24fv16km204 family devices have two variants. the km20x variant provides the full feature set of the device, while the km10x offers a reduced periph- eral set, allowing for the balance of features and cost (refer to tab l e 1 - 1 ). both variants allow for a smooth migration path as applications grow and evolve. the consistent pinout scheme used throughout the entire family also helps in migrating to the next larger device. this is true when moving between devices with the same pin count, different die variants, or even moving from 20-pin or 28-pin devices to 44-pin/48-pin devices. the pic24f family is pin compatible with devices in the dspic33 family, and shares some compatibility with the pinout schema for pic18 and dspic30. this extends the ability of applications to grow from the relatively simple to the powerful and complex, yet still selecting a microchip device. 1.2 other special features communications: the pic24fv16km204 family incorporates a range of serial communication peripherals to handle a range of application requirements. there is an mssp module which implements both spi and i 2 c? protocols, and supports both master and slave modes of operation for each. devices also include one of two uarts with built-in irda ? encoders/decoders. analog features: select members of the pic24fv16km204 family include two 8-bit digital-to-analog converters which offer support in idle mode, and left and right justified input data, as well as up to two operational amplifiers with selectable power and speed modes. real-time clock/calendar (rtcc): this module implements a full-featured clock and calendar with alarm functions in hardware, freeing up timer resources and program memory space for use of the core application. 12-bit a/d converter: this module incorporates programmable acquisition time, allowing for a channel to be selected and a conversion to be initiated without waiting for a sampling period, and faster sampling speed. the 16-deep result buffer can be used either in sleep, to reduce power, or in active mode to improve throughput. charge time measurement unit (ctmu) interface: the pic24fv16km204 family includes the new ctmu interface module, which can be used for capacitive touch sensing, proximity sensing, and also for precision time measurement and pulse generation. the ctmu can also be connected to the operational amplifiers to provide active guard- ing, which provides increased robustness in the presence of noise in capacitive touch applications. 1.3 details on individual family members devices in the pic24fv16km204 family are available in 20-pin, 28-pin, 44-pin and 48-pin packages. the general block diagram for all devices is shown in figure 1-1 . members of the pic24fv16k m204 family are available as both standard and high-voltage devices. high-voltage devices, designated with an fv in the part number (such as pic24fv16km204), accommodate an operat- ing v dd range of 2.0v to 5.5v and have an on-board voltage regulator that powers the core. peripherals operate at v dd . standard devices, designated by f (such as pic24f16km204), function over a lower v dd range of 1.8v to 3.6v. these parts do not have an internal regu- lator, and both the core and peripherals operate directly from v dd . the pic24fv16km204 family may be thought of as two different device groups, both offering slightly differ- ent sets of features. these differ from each other in multiple ways: the size of the flash program memory the number of external analog channels available the number of digital-to-analog converters the number of operational amplifiers the number of analog comparators the presence of a real-time clock and calendar (rtcc) the number and type of ccp modules (i.e., mccp vs. sccp) the number of serial communication modules (both mssps and uarts) the number of configurable logic cell (clc) modules the general differences between the different sub-families are shown in ta b l e 1 - 1 and ta b l e 1 - 2 . a list of the pin features available on the pic24fv16km204 family devices, sorted by function, is provided in table 1-5 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 15 pic24fv16km204 family table 1-1: device features for the pic24f16km204 family features pic24f16km204 pic24f08km204 pic24f16km202 pic24f08km202 operating frequency dc-32 mhz program memory (bytes) 16k 8k 16k 8k program memory (instructions) 5632 2816 5632 2816 data memory (bytes) 2048 data eeprom memory (bytes) 512 interrupt sources (soft vectors/nmi traps) 40 (36/4) voltage range 1.8-3.6v i/o ports porta<11:0> portb<15:0> portc<9:0> porta<7:0> portb<15:0> total i/o pins 38 24 timers 11 (one 16-bit timer, five mccps/sccps with up to two 16/32 timers each) capture/compare/pwm modules mccp sccp 32 serial communications mssp uart 22 input change notification interrupt 37 23 12-bit analog-to-digital module (input channels) 22 22 19 19 analog comparators 3 8-bit digital-to-analog converters 2 operational amplifiers 2 charge time measurement unit (ctmu) yes real-time clock and calendar (rtcc) yes configurable logic cell (clc) 2 resets (and delays) por, bor, reset instruction, mclr , wdt, illegal opcode, repeat instruction, hardware traps, configuration word mismatch (pwrt, ost, pll lock) instruction set 76 base instructions, multiple addressing mode variations packages 44-pin qfn/tqfp, 48-pin uqfn 28-pin spdip/ssop/soic/qfn downloaded from: http:///
pic24fv16km204 family ds30003030b-page 16 ? 2013 microchip technology inc. table 1-2: device features for the pic24f16km104 family features pic24f16km104 pic24f16km102 pic24f08km102 pic24f08km101 operating frequency dc-32 mhz program memory (bytes) 16k 16k 8k 8k program memory (instructions) 5632 5632 2816 2816 data memory (bytes) 1024 data eeprom memory (bytes) 512 interrupt sources (soft vectors/nmi traps) 25 (21/4) voltage range 1.8-3.6v i/o ports porta<11:0> portb<15:0> portc<9:0> porta<7:0> portb<15:0> porta<6:0> portb<15:12,9:7, 4,2:0> total i/o pins 38 24 18 timers 5 (one 16-bit timer, two mccps/sccps with up to two 16/32 timers each) capture/compare/pwm modules mccp sccp 11 serial communications mssp uart 11 input change notification interrupt 37 23 17 12-bit analog-to-digital module (input channels) 22 19 16 analog comparators 1 8-bit digital-to-analog converters operational amplifiers charge time measurement unit (ctmu) yes real-time clock and calendar (rtcc) configurable logic cell (clc) 1 resets (and delays) por, bor, reset instruction, mclr , wdt, illegal opcode, repeat instruction, hardware traps, configuration word mismatch (pwrt, ost, pll lock) instruction set 76 base instructions, multiple addressing mode variations packages 44-pin qfn/tqfp, 48-pin uqfn 28-pin spdip/ssop/soic/qfn 20-pin soic/ssop/pdip downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 17 pic24fv16km204 family table 1-3: device features for the pic24fv16km204 family features pic24fv16km204 pic24fv08km204 pic24fv16km202 pic24fv08km202 operating frequency dc-32 mhz program memory (bytes) 16k 8k 16k 8k program memory (instructions) 5632 2816 5632 2816 data memory (bytes) 2048 data eeprom memory (bytes) 512 interrupt sources (soft vectors/nmi traps) 40 (36/4) voltage range 2.0-5.5v i/o ports porta<11:7,5:0> portb<15:0> portc<9:0> porta<7,5:0> portb<15:0> total i/o pins 37 23 timers 11 (one 16-bit timer, five mccps/sccps with up to two 16/32 timers each) capture/compare/pwm modules mccp sccp 32 serial communications mssp uart 22 input change notification interrupt 36 22 12-bit analog-to-digital module (input channels) 22 19 analog comparators 3 8-bit digital-to-analog converters 2 operational amplifiers 2 charge time measurement unit (ctmu) yes real-time clock and calendar (rtcc) yes configurable logic cell (clc) 2 resets (and delays) por, bor, reset instruction, mclr , wdt, illegal opcode, repeat instruction, hardware traps, configuration word mismatch (pwrt, ost, pll lock) instruction set 76 base instructions, multiple addressing mode variations packages 44-pin qfn/tqfp, 48-pin uqfn 28-pin spdip/ssop/soic/qfn downloaded from: http:///
pic24fv16km204 family ds30003030b-page 18 ? 2013 microchip technology inc. table 1-4: device features for the pic24fv16km104 family features pic24fv16km104 pic24fv16km102 pic24fv08km102 pic24fv08km101 operating frequency dc-32 mhz program memory (bytes) 16k 16k 8k 8k program memory (instructions) 5632 5632 2816 2816 data memory (bytes) 1024 data eeprom memory (bytes) 512 interrupt sources (soft vectors/nmi traps) 25 (21/4) voltage range 2.0-5.5v i/o ports porta<11:7,5:0> portb<15:0> portc<9:0> porta<7,5:0> portb<15:0> porta<5:0> portb<15:12,9:7, 4,2:0> total i/o pins 37 23 17 timers 5 (one 16-bit timer, two mccps/sccps with up to two 16/32 timers each) capture/compare/pwm modules mccp sccp 11 serial communications mssp uart 11 input change notification interrupt 36 22 16 12-bit analog-to-digital module (input channels) 22 19 16 analog comparators 1 8-bit digital-to-analog converters operational amplifiers charge time measurement unit (ctmu) yes real-time clock and calendar (rtcc) configurable logic cell (clc) 1 resets (and delays) por, bor, reset instruction, mclr , wdt, illegal opcode, repeat instruction, hardware traps, configuration word mismatch (pwrt, ost, pll lock) instruction set 76 base instructions, multiple addressing mode variations packages 44-pin qfn/tqfp, 48-pin uqfn 28-pin spdip/ssop/soic/qfn 20-pin soic/ssop/pdip downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 19 pic24fv16km204 family figure 1-1: pic24fxxxxx family general block diagrams instruction decode and control 16 pch 16 program counter 23 24 data bus 16 divide support 16 16 16 8 interrupt controller psv and table data access control block repeat control logic data latch data ram address latch address latch program memory data latch 16 address bus literal data 23 control signals 16 16 16 x 16 w reg array multiplier 17x17 porta (1) ra<0:7> portb (1) rb<0:15> note 1: all pins or features are not implemented on all device pinout configurations. see table 1-5 for i/o port pin descriptions. comparators mccp1-3 ctmu op amp a/d 12-bit dac1/2 mssp1/2 clc1/2 cn1-36 (1) uart1/2 data eeprom osci/clki osco/clko v dd , v ss timing generation mclr power-up timer oscillator start-up timer power-on reset watchdog timer bor frc/lprc oscillators dswdt timer1 rtcc refo hlvd portc (1) rc<9:0> precision reference band gap voltage v cap regulator sccp4/5 (i 2 c?, spi) 1/2 pcl stack control logic read agu write agu ea mux inst latch inst register 16-bit alu downloaded from: http:///
pic24fv16km204 family ds30003030b-page 20 ? 2013 microchip technology inc. table 1-5: pic24fv16km204 fa mily pinout description function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn an0 2 2 27 19 21 2 2 27 19 21 i ana a/d analog inputs an1 3 3 28 20 22 3 3 28 20 22 i ana a/d analog inputs an2 4 4 1 21 23 4 4 1 21 23 i ana a/d analog inputs an3 5 5 2 22 24 5 5 2 22 24 i ana a/d analog inputs an4 6 6 3 23 25 6 6 3 23 25 i ana a/d analog inputs an5 7 4 24 26 7 4 24 26 i ana a/d analog inputs an6 25 27 25 27 i ana a/d analog inputs an7 26 28 26 28 i ana a/d analog inputs an8 27 29 27 29 i ana a/d analog inputs an9 18 26 23 15 16 18 26 23 15 16 i ana a/d analog inputs an10 17 25 22 14 15 17 25 22 14 15 i ana a/d analog inputs an11 16 24 21 11 12 16 24 21 11 12 i ana a/d analog inputs an12 15 23 20 10 11 15 23 20 10 11 i ana a/d analog inputs an13 7 9 6 30 33 7 9 6 30 33 i ana a/d analog inputs an14 8 10 7 31 34 8 10 7 31 34 i ana a/d analog inputs an15 9 11 8 33 36 9 11 8 33 36 i ana a/d analog inputs an16 10 12 9 34 37 10 12 9 34 37 i ana a/d analog inputs an17 14 11 41 45 14 11 41 45 i ana a/d analog inputs an18 15 12 42 46 15 12 42 46 i ana a/d analog inputs an19 11 16 13 43 47 11 16 13 43 47 i ana a/d analog inputs an20 12 17 14 44 48 12 17 14 44 48 i ana a/d analog inputs an21 13 18 15 1 1 13 18 15 1 1 i ana a/d analog inputs ascl1 15 12 42 46 15 12 42 46 i/o i 2 c? alternate i2c1 clock input/output asda1 14 11 41 45 14 11 41 45 i/o i 2 c alternate i2c1 data input/output av dd 20 28 25 17 18 20 28 25 17 18 p a/d supply pins av ss 19 27 24 16 17 19 27 24 16 17 p a/d supply pins c1ina 8 7 4 24 26 8 7 4 24 26 i ana comparator 1 input a (+) c1inb 7 6 3 23 25 7 6 3 23 25 i ana comparator 1 input b (-) c1inc 5 5 2 22 24 5 5 2 22 24 i ana comparator 1 input c (+) c1ind 4 4 1 21 23 4 4 1 21 23 i ana comparator 1 input d (-) legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 21 pic24fv16km204 family c1out 17 25 22 14 15 17 25 22 14 15 o comparator 1 output c2ina 5 2 22 24 5 2 22 24 i ana comparator 2 input a (+) c2inb 4 1 21 23 4 1 21 23 i ana comparator 2 input b (-) c2inc 7 4 24 26 7 4 24 26 i ana comparator 2 input c (+) c2ind 6 3 23 25 6 3 23 25 i ana comparator 2 input d (-) c2out 20 17 7 7 16 13 43 47 o comparator 2 output c3ina 26 23 15 16 26 23 15 16 i ana comparator 3 input a (+) c3inb 25 22 14 15 25 22 14 15 i ana comparator 3 input b (-) c 3 i n c 22 71 9 2 122 71 92 1ia n a c o m p a r a t o r 3 i n p u t c ( + ) c3ind 4 1 21 23 4 1 21 23 i ana comparator 3 input d (-) c3out 17 14 44 48 17 14 44 48 o comparator 3 output c l c 1 o 1 31 81 5 1 1 1 31 81 5 1 1oc l c 1 o u t p u t clc2o 19 16 6 6 19 16 6 6 o clc 2 output clcina 9 14 11 41 45 9 14 11 41 45 i st clc external input a clcinb 10 15 12 42 46 10 15 12 42 46 i st clc external input b clki 7 9 6 30 33 7 9 6 30 33 i ana primary clock input clko 8 10 7 31 34 8 10 7 31 34 o system clock output cn0 10 12 9 34 37 10 12 9 34 37 i st interrupt-on-change inputs cn1 9 11 8 33 36 9 11 8 33 36 i st interrupt-on-change inputs cn2 2 2 27 19 21 2 2 27 19 21 i st interrupt-on-change inputs cn3 3 3 28 20 22 3 3 28 20 22 i st interrupt-on-change inputs cn4 4 4 1 21 23 4 4 1 21 23 i st interrupt-on-change inputs cn5 5 5 2 22 24 5 5 2 22 24 i st interrupt-on-change inputs cn6 6 6 3 23 25 6 6 3 23 25 i st interrupt-on-change inputs cn7 7 4 24 26 7 4 24 26 i st interrupt-on-change inputs cn8 14 20 17 7 7 i st interrupt-on-change inputs cn9 19 16 6 6 19 16 6 6 i st interrupt-on-change inputs cn10 27 29 27 29 i st interrupt-on-change inputs cn11 18 26 23 15 16 18 26 23 15 16 i st interrupt-on-change inputs cn12 17 25 22 14 15 17 25 22 14 15 i st interrupt-on-change inputs table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
pic24fv16km204 family ds30003030b-page 22 ? 2013 microchip technology inc. cn13 16 24 21 11 12 16 24 21 11 12 i st interrupt-on-change inputs cn14 15 23 20 10 11 15 23 20 10 11 i st interrupt-on-change inputs cn15 22 19 9 10 22 19 9 10 i st interrupt-on-change inputs cn16 21 18 8 9 21 18 8 9 i st interrupt-on-change inputs cn17 3 3 3 3 i st interrupt-on-change inputs cn18 2 2 2 2 i st interrupt-on-change inputs cn19 5 5 5 5 i st interrupt-on-change inputs cn20 4 4 4 4 i st interrupt-on-change inputs cn21 13 18 15 1 1 13 18 15 1 1 i st interrupt-on-change inputs cn22 12 17 14 44 48 12 17 14 44 48 i st interrupt-on-change inputs cn23 11 16 13 43 47 11 16 13 43 47 i st interrupt-on-change inputs cn24 15 12 42 46 15 12 42 46 i st interrupt-on-change inputs cn25 37 40 37 40 i st interrupt-on-change inputs cn26 38 41 38 41 i st interrupt-on-change inputs cn27 14 11 41 45 14 11 41 45 i st interrupt-on-change inputs cn28 36 39 36 39 i st interrupt-on-change inputs cn29 8 10 7 31 34 8 10 7 31 34 i st interrupt-on-change inputs cn30 7 9 6 30 33 7 9 6 30 33 i st interrupt-on-change inputs cn31 26 28 26 28 i st interrupt-on-change inputs cn32 25 27 25 27 i st interrupt-on-change inputs cn33 32 35 32 35 i st interrupt-on-change inputs cn34 35 38 35 38 i st interrupt-on-change inputs cn35 12 13 12 13 i st interrupt-on-change inputs cn36 13 14 13 14 i st interrupt-on-change inputs ctcmp 4 4 1 21 23 4 4 1 21 23 i ana ctmu comparator input table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 23 pic24fv16km204 family cted1 11 20 17 7 7 11 2 27 19 21 i st ctmu trigger edge inputs cted2 15 23 20 10 11 15 23 20 10 11 i st ctmu trigger edge inputs cted3 19 16 6 6 19 16 6 6 i st ctmu trigger edge inputs cted4 13 18 15 1 1 13 18 15 1 1 i st ctmu trigger edge inputs cted5 17 25 22 14 15 17 25 22 14 15 i st ctmu trigger edge inputs cted6 18 26 23 15 16 18 26 23 15 16 i st ctmu trigger edge inputs cted7 5 5 5 5 i st ctmu trigger edge inputs cted8 13 14 13 14 i st ctmu trigger edge inputs cted9 22 19 9 10 22 19 9 10 i st ctmu trigger edge inputs cted10 12 17 14 44 48 12 17 14 44 48 i st ctmu trigger edge inputs cted11 21 18 8 9 21 18 8 9 i st ctmu trigger edge inputs cted12 5 5 2 22 24 5 5 2 22 24 i st ctmu trigger edge inputs cted13 6 6 3 23 25 6 6 3 23 25 i st ctmu trigger edge inputs ctpls 16 24 21 11 12 16 24 21 11 12 o ctmu pulse output cv ref 17 25 22 14 15 17 25 22 14 15 o ana comparator voltage reference output cv ref + 2 2 27 19 21 2 2 27 19 21 i ana comparator voltage reference positive input cv ref - 3 3 28 20 22 3 3 28 20 22 i ana comparator voltage reference negative input dac1out 23 20 10 11 23 20 10 11 o ana dac1 output dac1ref+ 2 27 19 21 2 27 19 21 i ana dac1 positive voltage reference input dac2out 25 22 14 15 25 22 14 15 o ana dac2 output dac2ref+ 26 23 15 16 26 23 15 16 i ana dac2 positive voltage reference input hlvdin 15 23 20 10 11 15 23 20 10 11 i ana external high/low-voltage detect input ic1 14 19 16 6 6 11 19 16 6 6 i st mccp1 input capture input ic2 13 18 15 1 1 13 18 15 1 1 i st mccp2 input capture input ic3 23 20 13 14 23 20 13 14 i st mccp3 input capture input ic4 14 11 5 5 14 11 5 5 i st sccp4 input capture input ic5 15 12 12 13 15 12 12 13 i st sccp5 input capture input int0 11 16 13 43 47 11 16 13 43 47 i st external interrupt 0 input int1 17 25 22 14 15 17 25 22 14 15 i st external interrupt 1 input int2 14 20 17 7 7 15 23 20 10 11 i st external interrupt 2 input table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
pic24fv16km204 family ds30003030b-page 24 ? 2013 microchip technology inc. mclr 1 1 26 18 19 1 1 26 18 19 i st master clear (device reset) input (active-low) oa1ina 5 2 22 24 5 2 22 24 i ana op amp 1 input a oa1inb 6 3 23 25 6 3 23 25 i ana op amp 1 input b oa1inc 24 21 11 12 24 21 11 12 i ana op amp 1 input c oa1ind 25 22 14 15 25 22 14 15 i ana op amp 1 input d oa1out 7 4 24 26 7 4 24 26 o ana op amp 1 analog output oa2ina 5 2 22 24 5 2 22 24 i ana op amp 2 input a oa2inb 6 3 23 25 6 3 23 25 i ana op amp 2 input b oa2inc 24 21 11 12 24 21 11 12 i ana op amp 2 input c oa2ind 25 22 14 15 25 22 14 15 i ana op amp 2 input d oa2out 26 23 15 16 26 23 15 16 o ana op amp 2 analog output oc1a 14 20 17 7 7 11 16 13 43 47 o mccp1 output compare a oc1b 12 17 14 44 48 12 17 14 44 48 o mccp1 output compare b oc1c 15 21 18 8 9 15 21 18 8 9 o mccp1 output compare c oc1d 16 24 21 11 12 16 24 21 11 12 o mccp1 output compare d oc1e 14 11 41 45 14 11 41 45 o mccp1 output compare e oc1f 15 12 42 46 15 12 42 46 o mccp1 output compare f oc2a 4 22 19 9 10 4 22 19 9 10 o mccp2 output compare a oc2b 23 20 10 11 23 20 10 11 o mccp2 output compare b oc2c 2 2 2 2 o mccp2 output compare c oc2d 3 3 3 3 o mccp2 output compare d oc2e 4 4 4 4 o mccp2 output compare e oc2f 5 5 5 5 o mccp2 output compare f oc3a 21 18 12 13 21 18 12 13 o mccp3 output compare a oc3b 24 21 13 14 24 21 13 14 o mccp3 output compare b oc4 18 15 1 1 18 15 1 1 o sccp4 output compare oc5 19 16 6 6 19 16 6 6 o sccp5 output compare ocfa 17 25 22 14 15 17 25 22 14 15 i st mccp/sccp output compare fault input a ocfb 16 24 21 32 35 16 24 21 32 35 i st mccp/sccp output compare fault input b table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 25 pic24fv16km204 family osci 7 9 6 30 33 7 9 6 30 33 i ana primary oscillator input osco 8 10 7 31 34 8 10 7 31 34 o ana primary oscillator output pgec1 5 5 2 22 24 5 5 2 22 24 i/o st icsp clock 1 pged1 4 4 1 21 23 4 4 1 21 23 i/o st icsp data 1 pgec2 2 22 19 9 10 2 22 19 9 10 i/o st icsp clock 2 pged2 3 21 18 8 9 3 21 18 8 9 i/o st icsp data 2 pgec3 10 15 12 42 46 10 15 12 42 46 i/o st icsp clock 3 pged3 9 14 11 41 45 9 14 11 41 45 i/o st icsp data 3 pwrlclk 10 12 9 34 37 10 12 9 34 37 i st rtcc power line clock input ra0 2 2 27 19 21 2 2 27 19 21 i/o st porta pins ra1 3 3 28 20 22 3 3 28 20 22 i/o st porta pins ra2 7 9 6 30 33 7 9 6 30 33 i/o st porta pins r a 3 81 073 13 481 073 13 4i / os tp o r t a p i n s ra4 10 12 9 34 37 10 12 9 34 37 i/o st porta pins ra5 1 1 26 18 19 1 1 26 18 19 i/o st porta pins ra6 14 20 17 7 7 i/o st porta pins ra7 19 16 6 6 19 16 6 6 i/o st porta pins ra8 32 35 32 35 i/o st porta pins ra9 35 38 35 38 i/o st porta pins ra10 12 13 12 13 i/o st porta pins ra11 13 14 13 14 i/o st porta pins rb0 4 4 1 21 23 4 4 1 21 23 i/o st portb pins rb1 5 5 2 22 24 5 5 2 22 24 i/o st portb pins rb2 6 6 3 23 25 6 6 3 23 25 i/o st portb pins rb3 7 4 24 26 7 4 24 26 i/o st portb pins r b 4 91 183 33 691 183 33 6i / os tp o r t b p i n s rb5 14 11 41 45 14 11 41 45 i/o st portb pins rb6 15 12 42 46 15 12 42 46 i/o st portb pins rb7 11 16 13 43 47 11 16 13 43 47 i/o st portb pins rb8 12 17 14 44 48 12 17 14 44 48 i/o st portb pins table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
pic24fv16km204 family ds30003030b-page 26 ? 2013 microchip technology inc. rb9 13 18 15 1 1 13 18 15 1 1 i/o st portb pins rb10 21 18 8 9 21 18 8 9 i/o st portb pins rb11 22 19 9 10 22 19 9 10 i/o st portb pins rb12 15 23 20 10 11 15 23 20 10 11 i/o st portb pins rb13 16 24 21 11 12 16 24 21 11 12 i/o st portb pins rb14 17 25 22 14 15 17 25 22 14 15 i/o st portb pins rb15 18 26 23 15 16 18 26 23 15 16 i/o st portb pins rc0 25 27 25 27 i/o st portc pins rc1 26 28 26 28 i/o st portc pins rc2 27 29 27 29 i/o st portc pins rc3 36 39 36 39 i/o st portc pins rc4 37 40 37 40 i/o st portc pins rc5 38 41 38 41 i/o st portc pins rc6 2 2 2 2 i/o st portc pins rc7 3 3 3 3 i/o st portc pins rc8 4 4 4 4 i/o st portc pins rc9 5 5 5 5 i/o st portc pins refo 18 26 23 15 16 18 26 23 15 16 o reference clock output rtcc 25 22 14 15 25 22 14 15 o real-time clock/calendar output sck1 15 22 19 9 10 15 22 19 9 10 i/o st mssp1 spi clock sdi1 17 21 18 8 9 17 21 18 8 9 i st mssp1 spi data input sdo1 16 24 21 11 12 16 24 21 11 12 o mssp1 spi data output ss1 18 26 23 15 16 18 26 23 15 16 i st mssp1 spi slave select input sck2 14 11 38 41 14 11 38 41 i/o st mssp2 spi clock sdi2 19 16 36 39 19 16 36 39 i st mssp2 spi data input sdo2 15 12 37 40 15 12 37 40 o mssp2 spi data output ss2 23 20 35 38 23 20 35 38 i st mssp2 spi slave select input table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 27 pic24fv16km204 family scl1 12 17 14 44 48 12 17 14 44 48 i/o i2c mssp1 i 2 c clock sda1 13 18 15 1 1 13 18 15 1 1 i/o i2c mssp1 i 2 c data scl2 7 4 24 26 7 4 24 26 i/o i2c mssp2 i 2 c clock sda2 6 3 23 25 6 3 23 25 i/o i2c mssp2 i 2 c data sclki 10 12 9 34 37 10 12 9 34 37 i st secondary clock digital input sosci 9 11 8 33 36 9 11 8 33 36 i ana secondary oscillator input sosco 10 12 9 34 37 10 12 9 34 37 i ana secondary oscillator output t1ck 13 18 15 1 1 13 18 15 1 1 i st timer1 digital input cock tckia 18 26 23 15 16 18 26 23 15 16 i st mccp/sccp time base clock input a tckib 6 6 3 23 25 6 6 3 23 25 i st mccp/sccp time base clock input b u1cts 12 17 14 44 48 12 17 14 44 48 i st uart1 clear-to-send input u1rts 13 18 15 1 1 13 18 15 1 1 o uart1 request-to-send output u1bclk 13 18 15 1 1 13 18 15 1 1 o uart1 16x baud rate clock output u1rx 6 6 3 2 2 6 6 3 2 2 i st uart1 receive u1tx 11 16 13 3 3 11 16 13 3 3 o uart1 transmit u2cts 12 9 34 37 12 9 34 37 i st uart2 clear-to-send input u2rts 11 8 33 36 11 8 33 36 o uart2 request-to-send output u2bclk 13 18 15 1 1 13 18 15 1 1 o uart2 16x baud rate clock output u2rx 5 2 22 24 5 2 22 24 i st uart2 receive u2tx 4 1 21 23 4 1 21 23 o uart2 transmit ulpwu 4 4 1 21 23 4 4 1 21 23 i ana ultra low-power wake-up input vcap 14 20 17 7 7 p regulator external filter capacitor connection v dd 20 28 25 17,28,28 18,30,30 20 28 25 17,28,28 18,30,30 p device positive supply voltage v ddcore 14 20 17 7 7 p microcontroller core supply voltage v pp 1 1 26 18 19 1 1 26 18 19 p high-voltage programming pin v ref + 2 2 27 19 21 2 2 27 19 21 i ana a/d reference voltage positive input v ref - 3 3 28 20 22 3 3 28 20 22 i ana a/d reference voltage negative input v ss 19 27 24 16,29,29 17,31,31 19 27 24 16,29,29 17,31,31 p device ground return voltage table 1-5: pic24fv16km204 family pinout description (continued) function ff v i/o buffer description pin number pin number 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn 20-pin pdip/ ssop/ soic 28-pin pdip/ ssop/ soic 28-pin qfn 44-pin qfn/ tqfp 48-pin uqfn legend: ana = analog level input/output, st = schmitt trigger input buffer, i 2 c? = i 2 c/smbus input buffer downloaded from: http:///
pic24fv16km204 family ds30003030b-page 28 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 29 pic24fv16km204 family 2.0 guidelines for getting started with 16-bit microcontrollers 2.1 basic connection requirements getting started with the pic24fv16km204 family of 16-bit microcontrollers requires attention to a minimal set of device pin connections before proceeding with development. the following pins must always be connected: all v dd and v ss pins (see section 2.2 power supply pins ) all av dd and av ss pins, regardless of whether or not the analog device features are used (see section 2.2 power supply pins ) mclr pin (see section 2.3 master clear (mclr) pin ) v cap pins (see section 2.4 voltage regulator pin (v cap ) ) these pins must also be connected if they are being used in the end application: pgecx/pgedx pins used for in-circuit serial programming? (icsp?) and debugging purposes (see section 2.5 icsp pins ) osci and osco pins when an external oscillator source is used (see section 2.6 external oscillator pins ) additionally, the following pins may be required: v ref +/v ref - pins are used when external voltage reference for analog modules is implemented the minimum mandatory connections are shown in figure 2-1 . figure 2-1: recommended minimum connections note: the av dd and av ss pins must always be connected, regardless of whether any of the analog modules are being used. pic24fv16km204 v dd v ss v dd v ss v ss v dd av dd av ss v dd v ss c1 r1 v dd mclr v cap r2 c7 c2 (2) c3 (2) c4 (2) c5 (2) c6 (2) key (all values are recommendations): c1 through c6: 0.1 f, 20v ceramic c7: 10 f, 16v tantalum or ceramic r1: 10 k ? r2: 100 ? to 470 ? note 1: see section 2.4 voltage regulator pin (v cap ) for an explanation of v cap pin connections. 2: the example shown is for a pic24f device with five v dd /v ss and av dd /av ss pairs. other devices may have more or less pairs; adjust the number of decoupling capacitors appropriately. (1) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 30 ? 2013 microchip technology inc. 2.2 power supply pins 2.2.1 decoupling capacitors the use of decoupling capacitors on every pair of power supply pins, such as v dd , v ss , av dd and av ss , is required. consider the following criteria when using decoupling capacitors: value and type of capacitor: a 0.1 f (100 nf), 10-20v capacitor is recommended. the capacitor should be a low-esr device, with a resonance frequency in the range of 200 mhz and higher. ceramic capacitors are recommended. placement on the printed circuit board: the decoupling capacitors should be placed as close to the pins as possible. it is recommended to place the capacitors on the same side of the board as the device. if space is constricted, the capacitor can be placed on another layer on the pcb using a via; however, ensure that the trace length from the pin to the capacitor is no greater than 0.25 inch (6 mm). handling high-frequency noise: if the board is experiencing high-frequency noise (upward of tens of mhz), add a second ceramic type capaci- tor in parallel to the above described decoupling capacitor. the value of the second capacitor can be in the range of 0.01 f to 0.001 f. place this second capacitor next to each primary decoupling capacitor. in high-speed circuit designs, consider implementing a decade pair of capacitances as close to the power and ground pins as possible (e.g., 0.1 f in parallel with 0.001 f). maximizing performance: on the board layout from the power supply circuit, run the power and return traces to the decoupling capacitors first, and then to the device pins. this ensures that the decoupling capacitors are first in the power chain. equally important is to keep the trace length between the capacitor and the power pins to a minimum, thereby reducing pcb trace inductance. 2.2.2 tank capacitors on boards with power traces running longer than six inches in length, it is suggested to use a tank capac- itor for integrated circuits, including microcontrollers, to supply a local power source. the value of the tank capacitor should be determined based on the trace resistance that connects the power supply source to the device, and the maximum current drawn by the device in the application. in other words, select the tank capacitor so that it meets the acceptable voltage sag at the device. typical values range from 4.7 f to 47 f. 2.3 master clear (mclr ) pin the mclr pin provides two specific device functions: device reset, and device programming and debugging. if programming and debugging are not required in the end application, a direct connection to v dd may be all that is required. the addition of other components, to help increase the applications resistance to spurious resets from voltage sags, may be beneficial. a typical configuration is shown in figure 2-1 . other circuit designs may be implemented, depending on the applications requirements. during programming and debugging, the resistance and capacitance that can be added to the pin must be considered. device programmers and debuggers drive the mclr pin. consequently, specific voltage levels (v ih and v il ) and fast signal transitions must not be adversely affected. therefore, specific values of r1 and c1 will need to be adjusted based on the application and pcb requirements. for example, it is recommended that the capacitor, c1, be isolated from the mclr pin during programming and debugging operations by using a jumper ( figure 2-2 ). the jumper is replaced for normal run-time operations. any components associated with the mclr pin should be placed within 0.25 inch (6 mm) of the pin. figure 2-2: example of mclr pin connections note 1: r1 ? 10 k ? is recommended. a suggested starting value is 10 k ? . ensure that the mclr pin v ih and v il specifications are met. 2: r2 ? 470 ? will limit any current flowing into mclr from the external capacitor, c, in the event of mclr pin breakdown, due to electrostatic discharge (esd) or electrical overstress (eos). ensure that the mclr pin v ih and v il specifications are met. c1 r2 r1 v dd mclr pic24fxxkxx jp downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 31 pic24fv16km204 family 2.4 voltage regulator pin (v cap ) some of the pic24fv16km devices have an internal voltage regulator. these devices have the voltage regulator output brought out on the v cap pin. on the pic24f k devices with regulators, a low-esr (< 5 ? ) capacitor is required on the v cap pin to stabilize the voltage regulator output. the v cap pin must not be connected to v dd and must use a capacitor of 10 f connected to ground. the type can be ceramic or tantalum. suitable examples of capacitors are shown in table 2-1 . capacitors with equivalent specifications can be used. designers may use figure 2-3 to evaluate esr equivalence of candidate devices. the placement of this capacitor should be close to v cap . it is recommended that the trace length not exceed 0.25 inch (6 mm). refer to section 27.0 electrical characteristics for additional information. refer to section 27.0 electrical characteristics for information on v dd and v ddcore . figure 2-3: frequency vs. esr performance for suggested v cap note: this section applies only to pic24fv16km devices with an on-chip voltage regulator. 10 1 0.1 0.01 0.001 0.01 0.1 1 10 100 1000 10,000 frequency (mhz) esr ( ? ) note: typical data measurement at +25c, 0v dc bias. table 2-1: suitable capacitor equivalents make part # nominal capacitance base tolerance rated voltage temp. range tdk c3216x7r1c106k 10 f 10% 16v -55 to +125oc tdk c3216x5r1c106k 10 f 10% 16v -55 to +85oc panasonic ecj-3yx1c106k 10 f 10% 16v -55 to +125oc panasonic ecj-4yb1c106k 10 f 10% 16v -55 to +85oc murata grm32dr71c106ka01l 10 f 10% 16v -55 to +125oc murata grm31cr61c106kc31l 10 f 10% 16v -55 to +85oc downloaded from: http:///
pic24fv16km204 family ds30003030b-page 32 ? 2013 microchip technology inc. 2.4.1 considerations for ceramic capacitors in recent years, large value, low-voltage, surface-mount ceramic capacitors have become very cost effective in sizes up to a few tens of microfarad. the low-esr, small physical size and other properties make ceramic capacitors very attractive in many types of applications. ceramic capacitors are suitable for use with the inter- nal voltage regulator of this microcontroller. however, some care is needed in selecting the capacitor to ensure that it maintains sufficient capacitance over the intended operating range of the application. typical low-cost, 10 f ceramic capacitors are available in x5r, x7r and y5v dielectric ratings (other types are also available, but are less common). the initial toler- ance specifications for these types of capacitors are often specified as 10% to 20% (x5r and x7r), or -20%/+80% (y5v). however, the effective capacitance that these capacitors provide in an application circuit will also vary based on additional factors, such as the applied dc bias voltage and the temperature. the total in-circuit tolerance is, therefore, much wider than the initial tolerance specification. the x5r and x7r capacitors typically exhibit satisfac- tory temperature stability (ex: 15% over a wide temperature range, but consult the manufacturers data sheets for exact specifications). however, y5v capaci- tors typically have extreme temperature tolerance specifications of +22%/-82%. due to the extreme temperature tolerance, a 10 f nominal rated y5v type capacitor may not deliver enough total capacitance to meet minimum internal voltage regulator stability and transient response requirements. therefore, y5v capacitors are not recommended for use with the internal regulator if the application must operate over a wide temperature range. in addition to temperature tolerance, the effective capacitance of large value ceramic capacitors can vary substantially, based on the amount of dc voltage applied to the capacitor. this effect can be very signifi- cant, but is often overlooked or is not always documented. a typical dc bias voltage vs. capacitance graph for x7r type capacitors is shown in figure 2-4 . figure 2-4: dc bias voltage vs. capacitance characteristics when selecting a ceramic capacitor to be used with the internal voltage regulator, it is suggested to select a high-voltage rating, so that the operating voltage is a small percentage of the maximum rated capacitor volt- age. for example, choose a ceramic capacitor rated at 16v for the 3.3v or 2.5v core voltage. suggested capacitors are shown in table 2-1 . 2.5 icsp pins the pgecx and pgedx pins are used for in-circuit serial programming? (icsp?) and debugging pur- poses. it is recommended to keep the trace length between the icsp connector and the icsp pins on the device as short as possible. if the icsp connector is expected to experience an esd event, a series resistor is recommended, with the value in the range of a few tens of ohms, not to exceed 100 ? . pull-up resistors, series diodes, and capacitors on the pgecx and pgedx pins are not recommended as they will interfere with the programmer/debugger communi- cations to the device. if such discrete components are an application requirement, they should be removed from the circuit during programming and debugging. alternatively, refer to the ac/dc characteristics and timing requirements information in the respective device flash programming specification for information on capacitive loading limits, and pins, voltage input high (v ih ) and voltage input low (v il ) requirements. for device emulation, ensure that the communication channel select (i.e., pgecx/pgedx pins), programmed into the device, matches the physical connections for the icsp to the microchip debugger/emulator tool. for more information on available microchip development tools connection requirements, refer to section 26.0 development support . -80 -70 -60 -50 -40 -30 -20 -10 0 10 5 1011121314151617 dc bias voltage (vdc) capacitance change (%) 01234 67 89 16v capacitor 10v capacitor 6.3v capacitor downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 33 pic24fv16km204 family 2.6 external oscillator pins many microcontrollers have options for at least two oscillators: a high-frequency primary oscillator and a low-frequency secondary oscillator (refer to for section 9.0 oscillator configuration details). the oscillator circuit should be placed on the same side of the board as the device. place the oscillator circuit close to the respective oscillator pins with no more than 0.5 inch (12 mm) between the circuit components and the pins. the load capacitors should be placed next to the oscillator itself, on the same side of the board. use a grounded copper pour around the oscillator cir- cuit to isolate it from surrounding circuits. the grounded copper pour should be routed directly to the mcu ground. do not run any signal traces or power traces inside the ground pour. also, if using a two-sided board, avoid any traces on the other side of the board where the crystal is placed. layout suggestions are shown in figure 2-5 . in-line packages may be handled with a single-sided layout that completely encompasses the oscillator pins. with fine-pitch packages, it is not always possible to com- pletely surround the pins and components. a suitable solution is to tie the broken guard sections to a mirrored ground layer. in all cases, the guard trace(s) must be returned to ground. in planning the applications routing and i/o assign- ments, ensure that adjacent port pins and other signals, in close proximity to the oscillator, are benign (i.e., free of high frequencies, short rise and fall times, and other similar noise). for additional information and design guidance on oscillator circuits, please refer to these microchip application notes, available at the corporate web site ( www.microchip.com ): an826, crystal oscillator basics and crystal selection for rfpic? and picmicro ? devices an849, basic picmicro ? oscillator design an943, practical picmicro ? oscillator analysis and design an949, making your oscillator work 2.7 unused i/os unused i/o pins should be configured as outputs and driven to a logic low state. alternatively, connect a 1 k ? to 10 k ? resistor to v ss on unused pins and drive the output to logic low. figure 2-5: suggested placement of the oscillator circuit gnd `` ` osc1 osc2 t1oso t1os i copper pour primary oscillator crystal timer1 oscillator crystal device pins primary oscillator c1c2 t1 oscillator: c1 t1 oscillator: c2 (tied to ground) single-sided and in-line layouts: fine-pitch (dual-sided) layouts: gnd osco osci bottom layer copper pour oscillator crystal top layer copper pour c2 c1 device pins (tied to ground) (tied to ground) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 34 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 35 pic24fv16km204 family 3.0 cpu the pic24f cpu has a 16-bit (data) modified harvard architecture with an enhanced instruction set and a 24-bit instruction word with a variable length opcode field. the program counter (pc) is 23 bits wide and addresses up to 4m instructions of user program memory space. a single-cycle instruction prefetch mechanism is used to help maintain throughput and provides predictable execution. all instructions execute in a single cycle, with the exception of instructions that change the program flow, the double-word move ( mov.d ) instruction and the table instructions. overhead-free program loop constructs are supported using the repeat instructions, which are interruptible at any point. pic24f devices have sixteen, 16-bit working registers in the programmers model. each of the working registers can act as a data, address or address offset register. the 16 th working register (w15) operates as a software stack pointer (ssp) for interrupts and calls. the upper 32 kbytes of the data space (ds) memory map can optionally be mapped into program space at any 16k word boundary of either program memory or data eeprom memory, defined by the 8-bit program space visibility page address (psvpag) register. the program to data space mapping feature lets any instruction access program space as if it were data space. the instruction set architecture (isa) has been signifi- cantly enhanced beyond that of the pic18, but maintains an acceptable level of backward compatibil- ity. all pic18 instructions and addressing modes are supported, either directly, or through simple macros. many of the isa enhancements have been driven by compiler efficiency needs. the core supports inherent (no operand), relative, literal, memory direct and three groups of addressing modes. all modes support register direct and various register indirect modes. each group offers up to seven addressing modes. instructions are associated with predefined addressing modes depending upon their functional requirements. for most instructions, the core is capable of executing a data (or program data) memory read, a working register (data) read, a data memory write and a pro- gram (instruction) memory read per instruction cycle. as a result, three parameter instructions can be supported, allowing trinary operations (i.e., a + b = c) to be executed in a single cycle. a high-speed, 17-bit by 17-bit multiplier has been included to significantly enhance the core arithmetic capability and throughput. the multiplier supports signed, unsigned and mixed mode, 16-bit by 16-bit or 8-bit by 8-bit integer multiplication. all multiply instructions execute in a single cycle. the 16-bit alu has been enhanced with integer divide assist hardware that supports an iterative non-restoring divide algorithm. it operates in conjunction with the repeat instruction looping mechanism and a selection of iterative divide instructions to support 32-bit (or 16-bit), divided by 16-bit integer signed and unsigned division. all divide operations require 19 cycles to complete but are interruptible at any cycle boundary. the pic24f has a vectored exception scheme with up to eight sources of non-maskable traps and up to 118 interrupt sources. each interrupt source can be assigned to one of seven priority levels. a block diagram of the cpu is illustrated in figure 3-1 . 3.1 programmers model figure 3-2 displays the programmers model for the pic24f. all registers in the programmers model are memory mapped and can be manipulated directly by instructions. table 3-1 provides a description of each register. all registers associated with the programmers model are memory mapped. note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive refer- ence source. for more information on the cpu, refer to the pic24f family reference manual , cpu (ds39703). downloaded from: http:///
pic24fv16km204 family ds30003030b-page 36 ? 2013 microchip technology inc. figure 3-1: pic24f cp u core block diagram table 3-1: cpu core registers register(s) name description w0 through w15 working register array pc 23-bit program counter sr alu status register splim stack pointer limit value register tblpag table memory page address register psvpag program space visibility page address register rcount repeat loop counter register corcon cpu control register instruction decode and control pch 16 program counter 16-bit alu 23 23 24 23 data bus instruction reg 16 16 x 16 w register array divide support rom latch 16 ea mux ragu wagu 16 16 8 interrupt controller stack control logic loop control logic data latch data ram address latch control signals to various blocks program memory data latch address bus 16 literal data 16 16 hardware multiplier 16 to peripheral modules address latch data eeprom psv and table data access control block pcl downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 37 pic24fv16km204 family figure 3-2: programmers model novz c tblpag 22 0 7 0 0 15 program counter table memory page alu status register (sr) working/address registers w0 (wreg) w1w2 w3 w4 w5 w6 w7 w8 w9 w10 w11 w12 w13 frame pointer stack pointer psvpag 7 0 program space visibility ra 0 rcount 15 0 repeat loop counter splim stack pointer limit srl registers or bits are shadowed for push.s and pop.s instructions. 0 0 page address register 15 0 cpu control register (corcon) srh w14 w15 dc ipl 210 ipl3 psv pc divider working registers multiplier registers 15 0 value register address register register downloaded from: http:///
pic24fv16km204 family ds30003030b-page 38 ? 2013 microchip technology inc. 3.2 cpu control registers register 3-1: sr: alu status register u-0 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0, hsc d c bit 15 bit 8 r/w-0, hsc ( 1 ) r/w-0, hsc ( 1 ) r/w-0, hsc ( 1 ) r-0, hsc r/w-0, hsc r/w-0, hsc r/w-0, hsc r/w-0, hsc ipl2 ( 2 ) ipl1 ( 2 ) ipl0 ( 2 ) ra n ov z c bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-9 unimplemented: read as 0 bit 8 dc: alu half carry/borrow bit 1 = a carry-out from the 4 th low-order bit (for byte-sized data) or 8 th low-order bit (for word-sized data) of the result occurred 0 = no carry-out from the 4 th or 8 th low-order bit of the result has occurred bit 7-5 ipl<2:0>: cpu interrupt priority level status bits ( 1 , 2 ) 111 = cpu interrupt priority level is 7 (15); user interrupts are disabled 110 = cpu interrupt priority level is 6 (14) 101 = cpu interrupt priority level is 5 (13) 100 = cpu interrupt priority level is 4 (12) 011 = cpu interrupt priority level is 3 (11) 010 = cpu interrupt priority level is 2 (10) 001 = cpu interrupt priority level is 1 (9) 000 = cpu interrupt priority level is 0 (8) bit 4 ra: repeat loop active bit 1 = repeat loop in progress 0 = repeat loop not in progress bit 3 n: alu negative bit 1 = result was negative 0 = result was non-negative (zero or positive) bit 2 ov: alu overflow bit 1 = overflow occurred for signed (2s complement) arithmetic in this arithmetic operation 0 = no overflow has occurred bit 1 z: alu zero bit 1 = an operation, which effects the z bit, has set it at some time in the past 0 = the most recent operation, which effects the z bit, has cleared it (i.e., a non-zero result) bit 0 c: alu carry/borrow bit 1 = a carry-out from the most significant bit (msb) of the result occurred 0 = no carry-out from the most significant bit (msb) of the result occurred note 1: the iplx status bits are read-only when nstdis (intcon1<15>) = 1 . 2: the ipl<2:0> status bits are concatenated with the ipl3 bit (corcon<3>) to form the cpu interrupt priority level (ipl). the value in parentheses indicates the ipl when ipl3 = 1 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 39 pic24fv16km204 family 3.3 arithmetic logic unit (alu) the pic24f alu is 16 bits wide and is capable of addition, subtraction, bit shifts and logic operations. unless otherwise mentioned, arithmetic operations are 2s complement in nature. depending on the operation, the alu may affect the values of the carry (c), zero (z), negative (n), overflow (ov) and digit carry (dc) status bits in the sr register. the c and dc status bits operate as borrow and digit borrow bits, respectively, for subtraction operations. the alu can perform 8-bit or 16-bit operations, depending on the mode of the instruction that is used. data for the alu operation can come from the w register array, or data memory, depending on the addressing mode of the instruction. likewise, output data from the alu can be written to the w register array or a data memory location. the pic24f cpu incorporates hardware support for both multiplication and division. this includes a dedicated hardware multiplier and support hardware division for 16-bit divisor. 3.3.1 multiplier the alu contains a high-speed, 17-bit x 17-bit multiplier. it supports unsigned, signed or mixed sign operation in several multiplication modes: 16-bit x 16-bit signed 16-bit x 16-bit unsigned 16-bit signed x 5-bit (literal) unsigned 16-bit unsigned x 16-bit unsigned 16-bit unsigned x 5-bit (literal) unsigned 16-bit unsigned x 16-bit signed 8-bit unsigned x 8-bit unsigned register 3-2: corcon: cpu control register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 r/c-0, hsc r/w-0 u-0 u-0 i p l 3 ( 1 ) psv bit 7 bit 0 legend: c = clearable bit hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-4 unimplemented: read as 0 bit 3 ipl3: cpu interrupt priority level status bit ( 1 ) 1 = cpu interrupt priority level is greater than 7 0 = cpu interrupt priority level is 7 or less bit 2 psv: program space visibility in data space enable bit 1 = program space is visible in data space 0 = program space is not visible in data space bit 1-0 unimplemented: read as 0 note 1: user interrupts are disabled when ipl3 = 1 . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 40 ? 2013 microchip technology inc. 3.3.2 divider the divide block supports 32-bit/16-bit and 16-bit/16-bit signed and unsigned integer divide operations with the following data sizes: 1. 32-bit signed/16-bit signed divide 2. 32-bit unsigned/16-bit unsigned divide 3. 16-bit signed/16-bit signed divide 4. 16-bit unsigned/16-bit unsigned divide the quotient for all divide instructions ends up in w0 and the remainder in w1. sixteen-bit signed and unsigned div instructions can specify any w register for both the 16-bit divisor (wn), and any w register (aligned) pair (w(m + 1):wm) for the 32-bit dividend. the divide algorithm takes one cycle per bit of divisor, so both 32-bit/16-bit and 16-bit/16-bit instructions take the same number of cycles to execute. 3.3.3 multi-bit shift support the pic24f alu supports both single bit and single-cycle, multi-bit arithmetic and logic shifts. multi-bit shifts are implemented using a shifter block, capable of performing up to a 15-bit arithmetic right shift, or up to a 15-bit left shift, in a single cycle. all multi-bit shift instructions only support register direct addressing for both the operand source and result destination. a full summary of instructions that use the shift operation is provided in table 3-2 . table 3-2: instructions that use the si ngle and multi-bit shift operation instruction description asr arithmetic shift right source register by one or more bits. sl shift left source register by one or more bits. lsr logical shift right source register by one or more bits. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 41 pic24fv16km204 family 4.0 memory organization as with harvard architecture devices, the pic24f microcontrollers feature separate program and data memory space and busing. this architecture also allows the direct access of program memory from the data space (ds) during code execution. 4.1 program address space the program address memory space of the pic24f devices is 4m instructions. the space is addressable by a 24-bit value derived from either the 23-bit program counter (pc) during program ex ecution, or from a table operation or data space remapping, as described in section 4.3 interfacing program and data memory spaces . the user access to the program memory space is restricted to the lower half of the address range (000000h to 7fffffh). the exception is the use of tblrd/tblwt operations, which use tblpag<7> to permit access to the configuration bits and device id sections of the configuration memory space. memory maps for the pic24fv16km204 family of devices are displayed in figure 4-1 . figure 4-1: program space memory ma p for pic24fxxxxx family devices 000000h 0000feh 000002h 000100h f80010h f80012h fefffeh ffffffh 000004h 000200h 0001feh 000104h configuration memory space user memory space note: memory areas are not displayed to scale. reset address device config registers devid (2) goto instruction reserved alternate vector table reserved interrupt vector table pic24f16km ff0000h f7fffeh f80000h 800000h 7fffffh reserved unimplemented read 0 reset address devid (2) goto instruction reserved alternate vector table reserved interrupt vector table device config registers reserved unimplemented read 0 0015feh 002bfeh user flash program memory (5632 instructions) 7ffe00h data eeprom data eeprom flash program memory (2816 instructions) pic24f08km downloaded from: http:///
pic24fv16km204 family ds30003030b-page 42 ? 2013 microchip technology inc. 4.1.1 program memory organization the program memory space is organized in word-addressable blocks. although it is treated as 24 bits wide, it is more appropriate to think of each address of the program memory as a lower and upper word, with the upper byte of the upper word being unimplemented. the lower word always has an even address, while the upper word has an odd address ( figure 4-2 ). program memory addresses are always word-aligned on the lower word, and addresses are incremented or decremented by two during code execution. this arrangement also provides compatibility with data memory space addressing and makes it possible to access data in the program memory space. 4.1.2 hard memory vectors all pic24f devices reserve the addresses between 00000h and 000200h for hard-coded program execution vectors. a hardware reset vector is provided to redirect code execution from the default value of the pc on device reset to the actual start of code. a goto instruction is programmed by the user at 000000h with the actual address for the start of code at 000002h. pic24f devices also have two interrupt vector tables, located from 000004h to 0000ffh, and 000104h to 0001ffh. these vector tables allow each of the many device interrupt sources to be handled by separate isrs. section 8.1 interrupt vector table (ivt) discusses the interrupt vector tables in more detail. 4.1.3 data eeprom in the pic24fv16km204 family, the data eeprom is mapped to the top of the user program memory space, starting at address, 7ffe00, and expanding up to address, 7fffff. the data eeprom is organized as 16-bit-wide mem- ory and 256 words deep. this memory is accessed using table read and write operations similar to the user code memory. 4.1.4 device configuration words table 4-1 provides the addresses of the device config- uration words for the pic24fv16km204 family. their location in the memory map is displayed in figure 4-1 . refer to section 25.1 configuration bits for more information on device configuration words. table 4-1: device configuration words for pic24fxxxxx family devices figure 4-2: program memory organization configuration word configuration word addresses fbs f80000 fgs f80004 foscsel f80006 fosc f80008 fwdt f8000a fpor f8000c ficd f8000e 0 8 16 pc address 000000h 000002h 000004h 000006h 23 00000000 00000000 00000000 00000000 program memory phantom byte (read as 0 ) least significant word most significant word instruction width 000001h 000003h 000005h 000007h msw address (lsw address) downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 43 pic24fv16km204 family 4.2 data address space the pic24f core has a separate, 16-bit-wide data memory space, addressable as a single linear range. the data space is accessed using two address generation units (agus), one each for read and write operations. the data space memory map is displayed in figure 4-3 . all effective addresses (eas) in the data memory space are 16 bits wide and point to bytes within the data space. this gives a data space address range of 64 kbytes or 32k words. the lower half of the data memory space (that is, when ea<15> = 0 ) is used for implemented memory addresses, while the upper half (ea<15> = 1 ) is reserved for the program space visibil- ity (psv) area (see section 4.3.3 reading data from program memory using program space visibility ). depending on the particular device, pic24fv16km family devices implement either 512 or 1024 words of data memory. should an ea point to a location outside of this area, an all zero word or byte will be returned. 4.2.1 data space width the data memory space is organized in byte-addressable, 16-bit-wide blocks. data is aligned in data memory and registers as 16-bit words, but all the data space eas resolve to bytes. the least significant bytes (lsbs) of each word have even addresses, while the most significant bytes (msbs) have odd addresses. figure 4-3: data space memory map for pic24fxxxxx family devices ( 3 ) 0000h 07feh fffeh lsb address lsb msb msb address 0001h 07ffh 0bffh (2) ffffh 8001h 8000h 7fffh 0801h 0800h near 0bfeh (2) sfr sfr space 7fffh program space visibility area note 1: upper data memory boundary for pic24fxxkm10x devices. 2: upper data memory boundary for pic24fxxkm20x devices. 3: data memory areas are not shown to scale. 1ffeh 1fffh space data space implemented data ram unimplemented read as 0 09ffh (1) 09feh (1) data ram downloaded from: http:///
pic24fv16km204 family ds30003030b-page 44 ? 2013 microchip technology inc. 4.2.2 data memory organization and alignment to maintain backward compatibility with pic ? devices and improve data space memory usage efficiency, the pic24f instruction set supports both word and byte operations. as a consequence of byte accessibility, all ea calculations are internally scaled to step through word-aligned memory. for example, the core recog- nizes that post-modified register indirect addressing mode [ws++] will result in a value of ws + 1 for byte operations and ws + 2 for word operations. data byte reads will read the complete word, which contains the byte, using the lsb of any ea to determine which byte to select. the selected byte is placed onto the lsb of the data path. that is, the data memory and the registers are organized as two parallel, byte-wide entities with shared (word) address decode, but separate write lines. data byte writes only write to the corresponding side of the array or register, which matches the byte address. all word accesses must be aligned to an even address. misaligned word data fetches are not supported, so care must be taken when mixing byte and word operations, or translating from 8-bit mcu code. if a mis- aligned read or write is attempted, an address error trap will be generated. if the error occurred on a read, the instruction underway is completed; if it occurred on a write, the instruction will be executed, but the write will not occur. in either case, a trap is then executed, allowing the system and/or user to examine the machine state prior to execution of the address fault. all byte loads into any w register are loaded into the lsb; the msb is not modified. a sign-extend ( se ) instruction is provided to allow the users to translate 8-bit signed data to 16-bit signed values. alternatively, for 16-bit unsigned data, users can clear the msb of any w register by executing a zero-extend ( ze ) instruction on the appropriate address. although most instructions are capable of operating on word or byte data sizes, it should be noted that some instructions operate only on words. 4.2.3 near data space the 8-kbyte area between 0000h and 1fffh is referred to as the near data space. locations in this space are directly addressable via a 13-bit absolute address field within all memory direct instructions. the remainder of the data space is addressable indirectly. additionally, the whole data space is addressable using mov instruc- tions, which support memory direct addressing (mda) with a 16-bit address field. for pic24fv16km204 family devices, the entire implemented data memory lies in near data space (nds). 4.2.4 sfr space the first 2 kbytes of the near data space, from 0000h to 07ffh, are primarily occupied with special function registers (sfrs). these are used by the pic24f core and peripheral modules for controlling the operation of the device. sfrs are distributed among the modules that they control and are generally grouped together by that module. much of the sfr space contains unused addresses; these are read as 0 . the sfr space, where the sfrs are actually implemented, is provided in ta b l e 4 - 2 . each implemented area indicates a 32-byte region where at least one address is implemented as an sfr. a complete listing of implemented sfrs, including their addresses, is provided in table 4-3 through ta b l e 4 - 2 6 . table 4-2: implemented regions of sfr data space sfr space address xx00 xx20 xx40 xx60 xx80 xxa0 xxc0 xxe0 000h core icn interrupts 100h timers clc mccp/sccp 200h mssp uart op amp dac i / o 300h a/d/cmtu 400h a n s e l 500h 600h rtcc/comp band gap 700h s y s t e m / hlvd nvm/pmd legend: = no implemented sfrs in this block. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 45 pic24fv16km204 family table 4-3: cpu core registers map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets wreg0 0h wreg0 0000 wreg1 2h wreg1 0000 wreg2 4h wreg2 0000 wreg3 6h wreg3 0000 wreg4 8h wreg4 0000 wreg5 ah wreg5 0000 wreg6 ch wreg6 0000 wreg7 eh wreg7 0000 wreg8 10h wreg8 0000 wreg9 12h wreg9 0000 wreg10 14h wreg10 0000 wreg11 16h wreg11 0000 wreg12 18h wreg12 0000 wreg13 1ah wreg13 0000 wreg14 1ch wreg14 0000 wreg15 1eh wreg15 0800 splim 20h splim register xxxx pcl 2eh pcl register 0000 pch 30h pch7 pch6 pch5 pch4 pch3 pch2 pch1 pch0 0000 tblpag 32h tblpag7 tblpag6 tblpag5 tblpag4 tblpag3 tblpag2 tblpag1 tblpag0 0000 psvpag 34h psvpag7 psvpag6 psvpag5 psvpag4 psvpag3 psvpag2 psvpag1 psvpag0 0000 rcount 36h rcount register xxxx sr 42h dc ipl2 ipl1 ipl0 ra n ov z c 0000 corcon 44h i p l 3p s v 0000 disicnt 52h disicnt13 disicnt12 disicnt11 disicnt10 disicnt9 disicnt8 disicnt7 disicn t6 disicnt5 disicnt4 disicnt3 disicnt2 disicnt1 disicnt0 xxxx legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 46 ? 2013 microchip technology inc. table 4-4: icn register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets cnpd1 56h cn15pde ( 1 , 2 ) cn14pde cn13pde cn12pde cn11pde cn10pde ( 2 ) cn9pde ( 1 , 2 ) c n 7 p d e ( 1 , 2 ) cn6pde cn5pde cn4pde cn3pde cn2pde cn1pde cn0pde 0000 cnpd2 58h cn31pde ( 2 ) cn30pde cn29pde cn28pde ( 2 ) cn27pde ( 1 , 2 ) cn26pde ( 2 ) cn25pde ( 2 ) cn24pde ( 1 , 2 ) cn23pde cn22pde cn21pde cn20pde ( 2 ) cn19pde ( 2 ) cn18pde ( 2 ) cn17pde ( 2 ) cn16pde ( 1 , 2 ) 0000 cnpd3 5ah cn36pde ( 2 ) cn35pde ( 2 ) cn34pde ( 2 ) cn33pde ( 2 ) cn32pde ( 2 ) 0000 cnen1 62h cn15ie ( 1 , 2 ) cn14ie cn13ie cn12ie cn11ie cn10ie ( 2 ) cn9ie ( 1 , 2 ) c n 7 i e ( 1 , 2 ) cn6ie cn5ie cn4ie cn3ie cn2ie cn1ie cn0ie 0000 cnen2 64h cn31ie ( 2 ) cn30ie cn29ie cn28ie ( 2 ) cn27ie ( 1 , 2 ) cn26ie ( 2 ) cn25ie ( 2 ) cn24ie ( 1 , 2 ) cn23ie cn22ie cn21ie cn20ie ( 2 ) cn19ie ( 2 ) cn18ie ( 2 ) cn17ie ( 2 ) cn16ie ( 1 , 2 ) 0000 cnen3 66h c n 3 6 i e ( 2 ) cn35ie ( 2 ) cn34ie ( 2 ) cn33ie ( 2 ) cn32ie ( 2 ) 0000 cnpu1 6eh cn15pue ( 1 , 2 ) cn14pue cn13pue cn12pue cn11pue cn10pue ( 2 ) cn9pue ( 1 , 2 ) c n 7 p u e ( 1 , 2 ) cn6pue cn5pue cn4pue cn3pue cn2pue cn1pue cn0pue 0000 cnpu2 70h cn31pue ( 2 ) cn30pue cn29pue cn28pue ( 2 ) cn27pue ( 1 , 2 ) cn26pue ( 2 ) cn25pue ( 2 ) cn24pue ( 1 , 2 ) cn23pue cn22pue cn21pue cn20pue ( 2 ) cn19pue ( 2 ) cn18pue ( 2 ) cn17pue ( 2 ) cn16pue ( 1 , 2 ) 0000 cnpu3 72h cn36pue ( 2 ) cn35pue ( 2 ) cn34pue ( 2 ) cn33pue ( 2 ) cn32pue ( 2 ) 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these bits are available only on 28-pin devices 2: these bits are available only on 44-pin devices downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 47 pic24fv16km204 family table 4-5: interrupt controller register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bi t 0 all resets intcon1 80h nstdis matherr addrerr stkerr oscfail 0000 intcon2 82h altivt disi int2ep int1ep int0ep 0000 ifs0 84h nvmif ad1if u1txif u1rxif cct2if cct1if ccp4if ccp3if t1if ccp2if ccp1if int0if 0000 ifs1 86h u2txif u2rxif int2if cct4if cct3if ccp5if int1if cnif cmif bcl1if ssp1if 0000 ifs2 88h cct5if 0000 ifs3 8ah r t c i f bcl2if ssp2if 0000 ifs4 8ch dac2if dac1if ctmuif h l v d i f u2erif u1erif 0000 ifs5 8eh u l p w u i f 0000 ifs6 90h clc2if clc1if 0000 iec0 94h nvmie ad1ie u1txie u1rxie cct2ie cct1ie ccp4ie ccp3ie t1ie ccp2ie ccp1ie int0ie 0000 iec1 96h u2txie u2rxie int2ie cct4ie cct3ie ccp5ie int1ie cnie cmie bcl1ie ssp1ie 0000 iec2 98h cct5ie 0000 iec3 9ah r t c i e bcl2ie ssp2ie 0000 iec4 9ch dac2ie dac1ie ctmuie h l v d i e u2erie u1erie 0000 iec5 9eh u l p w u i e 0000 iec6 a0h clc2ie clc1ie 0000 ipc0 a4h t1ip2 t1ip1 t1ip0 ccp2ip2 ccp2ip1 ccp2ip0 ccp1ip2 ccp1ip1 ccp1ip0 int0ip2 int0ip1 int0ip0 4444 ipc1 a6h cct1ip2 cct1ip1 cct1ip0 ccp4ip2 ccp4ip1 ccp4ip0 ccp3ip2 ccp3ip1 ccp3ip0 4440 ipc2 a8h u1rxip2 u1rxip1 u1rxip0 cct2ip2 cct2ip1 cct2ip0 4004 ipc3 aah nvmip2 nvmip1 nvmip0 ad1ip2 ad1ip1 ad1ip0 u1txip2 u1txip1 u1txip0 4044 ipc4 ach cnip2 cnip1 cnip0 cmip2 cmip1 cmip0 bcl1ip2 bcl1ip1 bcl1ip0 ssp1ip2 ssp1ip1 ssp1ip0 4444 ipc5 aeh ccp5ip2 ccp5ip1 ccp5ip0 int1ip2 int1ip1 int1ip0 0404 ipc6 b0h cct3ip2 cct3ip1 cct3ip0 4000 ipc7 b2h u2txip2 u2txip1 u2txip0 u2rxip2 u2rxip1 u2rxip0 int2ip2 int2ip1 int2ip0 cct4ip2 cct4ip1 cct4ip0 4444 ipc10 b8h cct5ip2 cct5ip1 cct5ip0 0040 ipc12 bch bcl2ip2 bcl2ip1 bcl2ip0 ssp2ip2 ssp2ip1 ssp2ip0 0440 ipc15 c2h rtcip2 rtcip1 rtcip0 0400 ipc16 c4h u2erip2 u2erip1 u2erip0 u1erip2 u1erip1 u1erip0 0440 ipc18 c8h hlvdip2 hlvdip1 hlvdip0 0004 ipc19 cah dac2ip2 dac2ip1 dac2ip0 dac1ip2 dac1ip1 dac1ip0 ctmuip2 ctmuip1 ctmuip0 4440 ipc20 cch ulpwuip2 ulpwuip1 ulpwuip0 0004 ipc24 d4h clc2ip2 clc2ip1 clc2ip0 clc1ip2 clc1ip1 clc1ip0 0044 inttreg e0h cpuirq v h o l d ilr3 ilr2 ilr1 ilr0 vecnum6 vecnum5 vecnum4 vecnum3 vecnum2 vecnum1 vecnum0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 48 ? 2013 microchip technology inc. table 4-6: timer1 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets tmr1 100h timer1 register xxxx pr1 102h timer1 period register ffff t1con 104h ton t s i d l tecs1 tecs0 tgate tckps1 tckps0 tsync tcs 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-7: clc1-2 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets clc1conl 122h lcen intp intn lcoe lcout lcpol mode2 mode1 mode0 0000 clc1conh 124h g4pol g3pol g2pol g1pol 0000 clc1sel 126h ds42 ds41 ds40 ds32 ds31 ds30 ds22 ds21 ds20 ds12 ds11 ds10 0000 clc1glsl 12ah g2d4t g2d4n g2d3t g2d3n g2d2t g2d2n g2d1t g2d1n g1d4t g1d4n g1d3t g1d3n g1d2t g1d2n g1d1t g1d1n 0000 clc1glsh 12ch g4d4t g4d4n g4d3t g4d3n g4d2t g4d2n g4d1t g4d1n g3d4t g3d4 n g3d3t g3d3n g3d2t g3d2n g3d1t g3d1n 0000 clc2conl ( 1 ) 12eh lcen intp intn lcoe lcout lcpol mode2 mode1 mode0 0000 clc2conh ( 1 ) 130h g4pol g3pol g2pol g1pol 0000 clc2sel ( 1 ) 132h ds42 ds41 ds40 ds32 ds31 ds30 ds22 ds21 ds20 ds12 ds11 ds10 0000 clc2glsl ( 1 ) 136h g2d4t g2d4n g2d3t g2d3n g2d2t g2d2n g2d1t g2d1n g1d4t g1d4n g1d3t g1d3n g1d2t g1d2n g1d1t g1d1n 0000 clc2glsh ( 1 ) 138h g4d4t g4d4n g4d3t g4d3n g4d2t g4d2n g4d1t g4d1n g3d4t g3d4n g3d3t g3d3n g3d2t g3d2n g3d1t g3d1n 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 49 pic24fv16km204 family table 4-8: mccp1 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ccp1con1l 140h ccpon ccpsidl r tmrsync clksel2 clksel1 clksel0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 0000 ccp1con1h 142h o pssrc rtrgen ops3 ops2 ops1 ops0 trigen oneshot altsync sync4 sync3 sync2 sync1 sync0 0000 ccp1con2l 144h pwmrsen asdgm ssdg asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 0000 ccp1con2h 146h oensync ocfen oceen ocden occen ocben ocaen icgsm1 icgsm0 auxout1 auxout0 ics2 ics1 ics0 0100 ccp1con3l 148h dt5 dt4 dt3 dt2 dt1 dt0 0000 ccp1con3h 14ah oetrig oscnt2 oscnt1 oscnt0 o u t m 2o u t m 1o u t m 0 polace polbdf pssace1 pssace0 pssbdf1 pssbdf0 0000 ccp1statl 14ch ccptrig trset trclr asevt scevt icdis icov icbne 0000 ccp1tmrl 150h mccp1 time base register low word 0000 ccp1tmrh 152h mccp1 time base register high word 0000 ccp1prl 154h mccp1 time base period register low word ffff ccp1prh 156h mccp1 time base period register high word ffff ccp1ral 158h output compare 1 data word a 0000 ccp1rbl 15ch output compare 1 data word b 0000 ccp1bufl 160h input capture 1 data buffer low word 0000 ccp1bufh 162h input capture 1 data buffer high word 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 50 ? 2013 microchip technology inc. table 4-9: mccp2 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ccp2con1l 164h ccpon ccpsidl r tmrsync clksel2 clksel1 clksel0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 0000 ccp2con1h 166h opssrc rtrgen iops3 iops2 iops1 iops0 trigen oneshot altsync sync4 sync3 sync2 sync1 sync0 0000 ccp2con2l 168h pwmrsen asdgm s s d g asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 0000 ccp2con2h 16ah oensync ocfen ( 1 ) oceen ( 1 ) ocden ( 1 ) occen ( 1 ) ocben ( 1 ) ocaen icgsm1 icgsm0 auxout1 auxout0 icsel2 icsel1 icsel0 0100 ccp2con3l 16ch dt5 dt4 dt3 dt2 dt1 dt0 0000 ccp2con3h 16eh oetrig oscnt2 oscnt1 oscnt0 o u t m 2 ( 1 ) outm1 ( 1 ) outm0 ( 1 ) polace polbdf ( 1 ) pssace1 pssace0 pssbdf1 ( 1 ) pssbdf0 ( 1 ) 0000 ccp2statl 170h ccptrig trset trclr asevt scevt icdis icov icbne 0000 ccp2tmrl 174h mccp2 time base register low word 0000 ccp2tmrh 176h mccp2 time base register high word 0000 ccp2prl 178h mccp2 time base period register low word ffff ccp2prh 17ah mccp2 time base period register high word ffff ccp2ral 17ch output compare 2 data word a 0000 ccp2rbl 180h output compare 2 data word b 0000 ccp2bufl 184h input capture 2 data buffer low word 0000 ccp2bufh 186h input capture 2 data buffer high word 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these bits are available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 51 pic24fv16km204 family table 4-10: mccp3 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ccp3con1l ( 1 ) 188h ccpon ccpsidl r tmrsync clksel2 clksel1 clksel0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 0000 ccp3con1h ( 1 ) 18ah opssrc rtrgen iops3 iops2 iops1 iops0 trigen oneshot altsync sync4 sync3 sync2 sync1 sync0 0000 ccp3con2l ( 1 ) 18ch pwmrsen asdgm s s d g asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 0000 ccp3con2h ( 1 ) 18eh oensync ocfen oceen ocden occen ocben ocaen icgsm1 icgsm0 auxout1 auxout0 ics2 ics1 ics0 0100 ccp3con3l ( 1 ) 190h dt5 dt4 dt3 dt2 dt1 dt0 0000 ccp3con3h ( 1 ) 192h oetrig oscnt2 oscnt1 oscnt0 outm2 outm1 outm0 polace polbdf pssace1 pssace0 pssbdf1 pssbdf0 0000 ccp3stat ( 1 ) 194h ccptrig trset trclr asevt scevt icdis icov icbne 0000 ccp3tmrl ( 1 ) 198h mccp3 time base register low word 0000 ccp3tmrh ( 1 ) 19ah mccp3 time base register high word 0000 ccp3prl ( 1 ) 19ch mccp3 time base period register low word ffff ccp3prh ( 1 ) 19eh mccp3 time base period register high word ffff ccp3ral ( 1 ) 1a0h output compare 3 data word a 0000 ccp3rbl ( 1 ) 1a4h output compare 3 data word b 0000 ccp3bufl ( 1 ) 1a8h input capture 3 data buffer low word 0000 ccp3bufh ( 1 ) 1aah input capture 3 data buffer high word 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 52 ? 2013 microchip technology inc. table 4-11: sccp4 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ccp4con1l ( 1 ) 1ach ccpon ccpsidl r tmrsync clksel2 clksel1 clksel0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 0000 ccp4con1h ( 1 ) 1aeh opssrc rtrgen iops3 iops2 iops1 iops0 trigen oneshot altsync sync4 sync3 sync2 sync1 sync0 0000 ccp4con2l ( 1 ) 1b0h pwmrsen asdgm ssdg asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 0000 ccp4con2h ( 1 ) 1b2h oensync ocaen icgsm1 icgsm0 auxout1 auxout0 icsel2 icsel1 icsel0 0100 ccp4con3h ( 1 ) 1b6h oetrig oscnt2 oscnt1 oscnt0 p o l a c e pssace1 pssace0 0000 ccp4statl ( 1 ) 1b8h ccptrig trset trclr asevt scevt icdis icov icbne 0000 ccp4tmrl ( 1 ) 1bch sccp4 time base register low word 0000 ccp4tmrh ( 1 ) 1beh sccp4 time base register high word 0000 ccp4prl ( 1 ) 1c0h sccp4 time base period register low word ffff ccp4prh ( 1 ) 1c2h sccp4 time base period register high word ffff ccp4ral ( 1 ) 1c4h output compare 4 data word a 0000 ccp4rbl ( 1 ) 1c8h output compare 4 data word b 0000 ccp4bufl ( 1 ) 1cch input capture 4 data buffer low word 0000 ccp4bufh ( 1 ) 1ceh input capture 4 data buffer high word 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 53 pic24fv16km204 family table 4-12: sccp5 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ccp5con1l ( 1 ) 1d0h ccpon ccpsidl r tmrsync clksel2 clksel1 clksel0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 0000 ccp5con1h ( 1 ) 1d2h opssrc rtrgen iops3 iops2 iops1 iops0 trigen oneshot altsync sync4 sync3 sync2 sync1 sync0 0000 ccp5con2l ( 1 ) 1d4h pwmrsen asdgm ssdg asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 0000 ccp5con2h ( 1 ) 1d6h oensync ocaen icgsm1 icgsm0 auxout1 auxout0 icsel2 icsel1 icsel0 0100 ccp5con3h ( 1 ) 1dah oetrig oscnt2 oscnt1 oscnt0 p o l a c e pssace1 pssace0 0000 ccp5statl ( 1 ) 1dch ccptrig trset trclr asevt scevt icdis icov icbne 0000 ccp5tmrl ( 1 ) 1e0h sccp5 time base register low word 0000 ccp5tmrh ( 1 ) 1e2h sccp5 time base register high word 0000 ccp5prl ( 1 ) 1e4h sccp5 time base period register low word ffff ccp5prh ( 1 ) 1e6h sccp5 time base period register high word ffff ccp5ral ( 1 ) 1e8h output compare 5 data word a 0000 ccp5rbl ( 1 ) 1ech output compare 5 data word b 0000 ccp5bufl ( 1 ) 1f0h input capture 5 data buffer low word 0000 ccp5bufh ( 1 ) 1f2h input capture 5 data buffer high word 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 54 ? 2013 microchip technology inc. table 4-13: mssp1 (i 2 c?/spi) register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ssp1buf 200h mssp1 receive buffer/transmit register 00xx ssp1con1 202h wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 ssp1con2 204h gcen ackstat ackdt acken rcen pen rsen sen 0000 ssp1con3 206h acktim pcie scie boen sdaht sbcde ahen dhen 0000 ssp1stat 208h s m p c k e d / a psr / w ua bf 0000 ssp1add 20ah mssp1 address register in i 2 c slave mode mssp1 baud rate reload register in i 2 c master mode 0000 ssp1msk 20ch msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 00ff legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-14: mssp2 (i 2 c?/spi) register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ssp2buf ( 1 ) 210h mssp2 receive buffer/transmit register 00xx ssp2con1 ( 1 ) 212h wcol sspov sspen ckp sspm3 sspm2 sspm1 sspm0 0000 ssp2con2 ( 1 ) 214h gcen ackstat ackdt acken rcen pen rsen sen 0000 ssp2con3 ( 1 ) 216h acktim pcie scie boen sdaht sbcde ahen dhen 0000 ssp2stat ( 1 ) 218h s m pc k e d / a psr / w ua bf 0000 ssp2add ( 1 ) 21ah mssp2 address register in i 2 c slave mode mssp2 baud rate reload register in i 2 c master mode 0000 ssp2msk ( 1 ) 21ch msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 00ff legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 55 pic24fv16km204 family table 4-15: uart1 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets u1mode 220h uarten usidl iren rtsmd uen1 uen0 wake lpback abaud urxinv brgh pdsel1 pdsel0 stsel 0000 u1sta 222h utxisel1 utxinv utxisel0 utxbrk utxen utxbf trmt urxisel1 urxisel0 adden ridle perr ferr oerr urxda 0110 u1txreg 224h uart1 transmit register xxxx u1rxreg 226h uart1 receive register 0000 u1brg 228h baud rate generator prescaler 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-16: uart2 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 b it 2 bit 1 bit 0 all resets u2mode ( 1 ) 230h uarten usidl iren rtsmd uen1 uen0 wake lpback abaud urxinv brgh pdsel1 pdsel0 stsel 0000 u2sta ( 1 ) 232h utxisel1 utxinv utxisel0 utxbrk utxen utxbf trmt urxisel1 urxisel0 adden ridle perr ferr oerr urxda 0110 u2txreg ( 1 ) 234h uart2 transmit register xxxx u2rxreg ( 1 ) 236h uart2 receive register 0000 u2brg ( 1 ) 238h baud rate generator prescaler 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 56 ? 2013 microchip technology inc. table 4-17: op amp 1 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets amp1con ( 1 ) 24ah ampen ampsidl ampslp spdsel ninsel2 ninsel1 ninsel0 pinsel2 pinsel1 pinsel0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: this registers are available only on pic24f(v)16km2xx devices. table 4-18: op amp 2 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets amp2con ( 1 ) 24ch ampen ampsidl ampslp spdsel ninsel2 ninsel1 ninsel0 pinsel2 pinsel1 pinsel0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: this registers are available only on pic24f(v)16km2xx devices. table 4-19: dac1 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 b it 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets dac1con ( 1 ) 274h dacen dacsidl dacslp dacfm srdis dactrig dacoe dactsel4 dactsel3 dactsel2 dactsel1 dactsel0 dacref1 dacref0 0000 dac1dat ( 1 ) 276h dacdat15 ( 2 ) dacdat14 ( 2 ) dacdat13 ( 2 ) dacdat12 ( 2 ) dacdat11 ( 2 ) dacdat10 ( 2 ) dacdat9 ( 2 ) dacdat8 ( 2 ) dacdat7 ( 2 ) dacdat6 ( 2 ) dacdat5 ( 2 ) dacdat4 ( 2 ) dacdat3 ( 2 ) dacdat2 ( 2 ) dacdat1 ( 2 ) dacdat0 ( 2 ) 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km1xx devices. 2: the 8-bit result format depends on the value of the dacfm control bit. table 4-20: dac2 register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets dac2con ( 1 ) 278h dacen dacsidl dacslp dacfm srdis dactrig dacoe dactsel4 dactsel3 dactsel2 dactsel1 dactsel0 da cref1 dacref0 0000 dac2dat ( 1 ) 27ah dacdat15 ( 2 ) dacdat14 ( 2 ) dacdat13 ( 2 ) dacdat12 ( 2 ) dacdat11 ( 2 ) dacdat10 ( 2 ) dacdat9 ( 2 ) dacdat8 ( 2 ) dacdat7 ( 2 ) dacdat6 ( 2 ) dacdat5 ( 2 ) dacdat4 ( 2 ) dacdat3 ( 2 ) dacdat2 ( 2 ) dacdat1 ( 2 ) dacdat0 ( 2 ) 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers are available only on pic24f(v)16km2xx devices. 2: the 8-bit result format depends on the value of the dacfm control bit. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 57 pic24fv16km204 family table 4-21: porta register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 ( 4 , 5 ) bit 10 ( 4 , 5 ) bit 9 ( 4 , 5 ) bit 8 ( 4 , 5 ) bit 7 ( 4 ) bit 6 ( 3 ) bit 5 ( 2 ) bit 4 bit 3 bit 2 bit 1 bit 0 all resets trisa 2c0h trisa11 trisa10 trisa9 trisa8 trisa7 trisa6 trisa4 trisa3 trisa2 trisa1 trisa0 0fdf ( 1 ) porta 2c2h ra11 ra10 ra9 ra8 ra7 ra6 ra5 ra4 ra3 ra2 ra1 ra0 xxxx lata 2c4h lata11 lata10 lata9 lata8 lata7 lata6 lata4 lata3 lata2 lata1 lata0 xxxx odca 2c6h oda11 oda10 oda9 oda8 oda7 oda6 oda4 oda3 oda2 oda1 oda0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: reset value depends on the device type; the pic24f16km204 value is shown. 2: these bits are only available when mclre (fpor<7>) = 0 . 3: these bits are not implemented in fv devices. 4: these bits are not implemented in 20-pin devices. 5: these bits are not implemented in 28-pin devices. table 4-22: portb register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 ( 2 ) bit 10 ( 2 ) bit 9 bit 8 bit 7 bit 6 ( 2 ) bit 5 ( 2 ) bit 4 bit 3 ( 2 ) bit 2 bit 1 bit 0 all resets trisb 2c8h trisb15 trisb14 trisb13 trisb12 trisb11 trisb10 trisb9 trisb8 trisb7 trisb6 trisb5 trisb4 trisb3 trisb2 trisb1 trisb0 ffff ( 1 ) portb 2cah rb15 rb14 rb13 rb12 rb11 rb10 rb9 rb8 rb7 rb6 rb5 rb4 rb3 rb2 rb1 rb0 xxxx latb 2cch latb15 latb14 latb13 latb12 latb11 latb10 latb9 latb8 latb7 latb6 la tb5 latb4 latb3 latb2 latb1 latb0 xxxx odcb 2ceh odb15 odb14 odb13 odb12 odb11 odb10 odb9 odb8 odb7 odb6 odb5 odb4 odb3 odb2 o db1 odb0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: reset value depends on the device type; the pic24f16km204 value is shown. 2: these bits are not implemented in 20-pin devices. table 4-23: portc register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 ( 2 , 3 ) bit 8 ( 2 , 3 ) bit 7 ( 2 , 3 ) bit 6 ( 2 , 3 ) bit 5 ( 2 , 3 ) bit 4 ( 2 , 3 ) bit 3 ( 2 , 3 ) bit 2 ( 2 , 3 ) bit 1 ( 2 , 3 ) bit 0 ( 2 , 3 ) all resets trisc 2d0h trisc9 trisc8 trisc7 trisc6 trisc5 trisc4 trisc3 trisc2 trisc1 trisc0 03ff ( 1 ) portc 2d2h rc9 rc8 rc7 rc6 rc5 rc4 rc3 rc2 rc1 rc0 xxxx lattc 2d4h latc9 latc8 latc7 latc6 latc5 latc4 latc3 latc2 latc1 latc0 xxxx odcc 2d6h odc9 odc8 odc7 odc6 odc5 odc4 odc3 odc2 odc1 odc0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: reset value depends on the device type; the pic24f16km204 value is shown. 2: these bits are not implemented in 20-pin devices. 3: these bits are not implemented in 28-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 58 ? 2013 microchip technology inc. table 4-24: pad config uration register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 b it 0 all resets padcfg1 2fch sdo2dis ( 1 ) sck2dis ( 1 ) sdo1dis sck1dis 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these bits are not available on the pic24f(v)08km101 device, read as 0 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 59 pic24fv16km204 family table 4-25: a/d register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 b it 0 all resets adc1buf0 300h a/d data buffer 0/threshold for c hannel 0/threshold for channel 0 & 12 in window compare xxxx adc1buf1 302h a/d data buffer 1/threshold for c hannel 1/threshold for channel 1 & 13 in window compare xxxx adc1buf2 304h a/d data buffer 2/threshold for c hannel 2/threshold for channel 2 & 14 in window compare xxxx adc1buf3 306h a/d data buffer 3/threshold for c hannel 3/threshold for channel 3 & 15 in window compare xxxx adc1buf4 308h a/d data buffer 4/threshold for c hannel 4/threshold for channel 4 & 16 in window compare xxxx adc1buf5 30ah a/d data buffer 5/threshold for channel 5/threshold for channel 5 & 17 in window compare xxxx adc1buf6 30ch a/d data buffer 6/threshold for channel 6/threshold for channel 6 & 18 in window compare xxxx adc1buf7 30eh a/d data buffer 7/threshold for channel 7/threshold for channel 7 & 19 in window compare xxxx adc1buf8 310h a/d data buffer 8/threshold for c hannel 8/threshold for channel 8 & 20 in window compare xxxx adc1buf9 312h a/d data buffer 9/threshold for c hannel 9/threshold for channel 9 & 21 in window compare xxxx adc1buf10 314h a/d data buffer 10/threshold for c hannel 10/threshold for channel 10 & 22 in window compare xxxx adc1buf11 316h a/d data buffer 11/threshold for c hannel 11/threshold for channel 11 & 23 in window compare xxxx adc1buf12 318h a/d data buffer 12/threshold for c hannel 12/threshold for channel 0 & 12 in window compare xxxx adc1buf13 31ah a/d data buffer 13/threshold for channel 13/threshold for channel 1 & 13 in window compare xxxx adc1buf14 31ch a/d data buffer 14/threshold for channel 14/threshold for channel 2 & 14 in window compare xxxx adc1buf15 31eh a/d data buffer 15/threshold for channel 15/threshold for channel 3 & 15 in window compare xxxx adc1buf16 320h a/d data buffer 16/threshold for c hannel 16/threshold for channel 4 & 16 in window compare xxxx adc1buf17 322h a/d data buffer 17/threshold for c hannel 17/threshold for channel 5 & 17 in window compare xxxx adc1buf18 324h a/d data buffer 18/threshold for c hannel 18/threshold for channel 6 & 18 in window compare xxxx adc1buf19 326h a/d data buffer 19/threshold for c hannel 19/threshold for channel 7 & 19 in window compare xxxx adc1buf20 328h a/d data buffer 20/threshold for c hannel 20/threshold for channel 8 & 20 in window compare xxxx adc1buf21 32ah a/d data buffer 21/threshold for channel 21/threshold for channel 9 & 21 in window compare xxxx adc1buf22 32ch a/d data buffer 22/threshold for channel 22/threshold for channel 10 & 22 in window compare xxxx adc1buf23 32eh a/d data buffer 23/threshold for channel 23/threshold for channel 11 & 23 in window compare xxxx ad1con1 340h adon adsidl mode12 form1 form0 ssrc3 ssrc2 ssrc1 ssrc0 asam samp done 0000 ad1con2 342h pvcfg1 pvcfg0 nvcfg0 bufregen cscna bufs smpi4 smpi3 smpi2 smpi1 smpi0 bufm alts 0000 ad1con3 344h adrc extsam samc4 samc3 samc2 samc1 samc0 adcs7 adcs6 adcs5 adcs4 adcs3 adcs2 adcs1 adcs0 0000 ad1chs 348h ch0nb2 ch0nb1 ch0nb0 ch0sb4 ch0sb3 ch0sb2 ch0sb1 ch0sb0 ch0na2 ch0na1 ch0na0 ch0sa4 ch0sa3 ch0sa2 ch0sa1 ch0sa0 0000 ad1cssh 34eh css30 css29 css28 css27 css26 css23 css22 css21 css20 ( 1 ) css19 ( 1 ) css18 css17 css16 0000 ad1cssl 350h css15 css14 css13 css12 css11 css10 css9 css8 ( 1 , 2 ) css7 ( 1 , 2 ) css6 ( 1 , 2 ) css5 ( 1 ) css4 css3 css2 css1 css0 0000 ad1con5 354h asen lpen ctmreq bgreq r asint1 asint0 wm1 wm0 cm1 cm0 0000 ad1chith 356h chh23 chh22 chh21 chh20 ( 1 ) chh19 ( 1 ) chh18 chh17 chh16 0000 ad1chitl 358h chh15 chh14 chh13 chh12 chh11 chh10 chh9 chh8 ( 1 , 2 ) chh7 ( 1 , 2 ) chh6 ( 1 , 2 ) chh5 ( 1 ) chh4 chh3 chh2 chh1 chh0 0000 ad1ctmenh 360h ctmen23 ctmen22 ctmen21 ctmen20 ( 1 ) ctmen19 ( 1 ) ctmen18 ctmen17 ctmen16 0000 ad1ctmenl 362h ctmen15 ctmen14 ctmen13 ctmen12 ctmen11 ctmen10 ctmen9 ctmen8 ( ( 1 , 2 ) ctmen7 ( 1 , 2 ) ctmen6 ( 1 , 2 ) ctmen5 ( 1 ) ctmen4 ctmen3 ctmen2 ctmen1 ctmen0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these bits are not implemented in 20-pin devices. 2: these bits are not implemented in 28-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 60 ? 2013 microchip technology inc. table 4-26: ctmu register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ctmucon1l 35ah ctmuen ctmusidl tgen edgen edgseqen idissen cttrig itrim5 itrim4 itrim3 itrim2 itrim1 itrim0 irng1 irng0 0000 ctmucon1h 35ch edg1mod edg1pol edg1sel3 edg1sel2 edg1sel1 edg1sel0 edg2stat edg1stat edg2mod edg2pol edg2sel3 edg2sel2 edg2sel1 edg2sel0 0000 ctmucon2l 35eh irsten dischs2 dischs1 dischs0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-27: ansel register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 b it 1 bit 0 all resets ansa 4e0h a n s a 4 ( 2 ) ansa3 ansa2 ansa1 ansa0 001f ( 1 ) ansb 4e2h ansb15 ansb14 ansb13 ansb12 ansb9 ansb8 ansb7 ansb6 ( 2 ) ansb5 ( 2 ) ansb4 ansb3 ( 2 ) ansb2 ansb1 ansb0 f3ff ( 1 ) ansc 4e4h ansc2 ( 2 , 3 ) ansc1 ( 2 , 3 ) ansc0 ( 2 , 3 ) 0007 ( 1 ) legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: reset value depends on the device type; the pic24f16km204 value is shown. 2: these bits are not implemented in 20-pin devices. 3: these bits are not implemented in 28-pin devices. table 4-28: real-time clock and calendar register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets alrmval 620h alarm value high register window based on aptr<1:0> xxxx alcfgrpt 622h alrmen chime amask3 amask2 amask1 amask0 alrmptr1 alrmptr0 arpt7 arpt6 arpt5 arpt4 arpt3 arpt2 arpt1 arpt0 0000 ( 1 ) rtcval 624h rtcc value high register window based on rtcptr<1:0> xxxx rcfgcal 626h rtcen rtcwren rtcsync halfsec rtcoe rtcptr1 rtcptr0 cal7 cal6 cal5 cal4 cal3 cal2 cal1 cal0 0000 ( 1 ) rtcpwc 628h pwcen pwcpol pwccpre pwcspre rtcclk1 rtcclk0 rtcout1 rtcout0 0000 ( 1 ) legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: values are reset only on a v dd por event. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 61 pic24fv16km204 family table 4-29: comparator register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets cmstat 630h cmidl c3evt ( 1 ) c2evt ( 1 ) c1evt c 3 o u t ( 1 ) c2out ( 1 ) c1out 0000 cvrcon 632h cvren cvroe cvrss cvr4 cvr3 cvr2 cvr1 cvr0 0000 cm1con 634h con coe cpol clpwr cevt cout evpol1 evpol0 cref1 cref0 cch1 cch0 0000 cm2con ( 1 ) 636h con coe cpol clpwr cevt cout evpol1 evpol0 cref1 ( 1 ) cref0 cch1 cch0 0000 cm3con ( 1 ) 638h con coe cpol clpwr cevt cout evpol1 evpol0 cref1 ( 1 ) cref0 cch1 cch0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these registers and bits are available only on pic24f(v)16km2xx devices. table 4-30: band gap buffer control register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets bufcon0 670h bufref1 bufref0 0001 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 62 ? 2013 microchip technology inc. table 4-31: clock control register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 b it 1 bit 0 all resets rcon 740h trapr iopuwr sboren reten cm pmslp extr swr swdten wdto sleep idle bor por (note 1 ) osccon 742h cosc2 cosc1 cosc0 nosc2 nosc1 nosc0 clklock l o c k cf soscdrv soscen oswen (note 2 ) clkdiv 744h roi doze2 doze1 doze0 dozen rcdiv2 rcdiv1 rcdiv0 0100 osctun 748h tun5 tun4 tun3 tun2 tun1 tun0 0000 refocon 74eh roen rosslp rosel rodiv3 rodiv2 rodiv1 rodiv0 0000 hlvdcon 756h hlvden h l s i d l vdir bgvst irvst hlvdl3 hlvdl2 hlvdl1 hlvdl0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: rcon register reset values are dependent on the type of reset. 2: osccon register reset values are dependent on configuration fuses and by type of reset. table 4-32: nvm register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets nvmcon 760h wr wren wrerr pgmonly erase nvmop5 nvmop4 nvmop3 nvmop2 nvmop1 nvmop0 0000 nvmkey 766h nvmkey7 nvmkey6 nvmkey5 nvmkey4 nvmkey3 nvmkey2 nvmkey1 nvmkey0 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-33: ultra low-power wake-up register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets ulpwcon 768h ulpen ulpsidl ulpsink 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. table 4-34: pmd register map file name addr. bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 all resets pmd1 770h t 1 m d ssp1md u2md ( 1 ) u1md adcmd 0000 pmd2 772h ccp5md ( 1 ) ccp4md ( 1 ) ccp3md ( 1 ) ccp2md ccp1md 0000 pmd3 774h cmpmd rtccmd d a c 1 m d ( 1 ) ssp2md ( 1 ) 0000 pmd4 776h u l p w u m d refomd ctmumd hlvdmd 0000 pmd6 77ah a m p 1 m d ( 1 ) dac2md ( 1 ) amp2md ( 1 ) 0000 pmd8 77eh c l c 2 m d ( 1 ) clc1md 0000 legend: x = unknown, u = unchanged, = unimplemented, q = value depends on condition, r = reserved. note 1: these bits are available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 63 pic24fv16km204 family 4.2.5 software stack in addition to its use as a working register, the w15 register in pic24f devices is also used as a software stack pointer. the pointer always points to the first available free word and grows from lower to higher addresses. it pre-decrements for stack pops and post-increments for stack pushes, as depicted in figure 4-4 . for a pc push during any call instruction, the msb of the pc is zero-extended before the push, ensuring that the msb is always clear. the stack pointer limit value (splim) register, associated with the stack pointer, sets an upper address boundary for the stack. splim is uninitialized at reset. as is the case for the stack pointer, splim<0> is forced to 0 as all stack operations must be word-aligned. whenever an ea is generated using w15 as a source or destination pointer, the resulting address is compared with the value in splim. if the contents of the stack pointer (w15) and the splim register are equal, and a push operation is performed, a stack error trap will not occur. the stack error trap will occur on a subsequent push operation. thus, for example, if it is desirable to cause a stack error trap when the stack grows beyond address, 0df6 in ram, initialize the splim with the value, 0df4. similarly, a stack pointer underflow (stack error) trap is generated when the stack pointer address is found to be less than 0800h. this prevents the stack from interfering with the special function register (sfr) space. figure 4-4: call stack frame 4.3 interfacing program and data memory spaces the pic24f architecture uses a 24-bit-wide program space and 16-bit-wide data space (ds). the architec- ture is also a modified harvard scheme, meaning that data can also be present in the program space. to use this data successfully, it must be accessed in a way that preserves the alignment of information in both spaces. apart from the normal execution, the pic24f architecture provides two methods by which the program space can be accessed during operation: using table instructions to access individual bytes or words anywhere in the program space remapping a portion of the program space into the data space, psv table instructions allow an application to read or write small areas of the program memory. this makes the method ideal for accessing data tables that need to be updated from time to time. it also allows access to all bytes of the program word. the remapping method allows an application to access a large block of data on a read-only basis, which is ideal for look ups from a large table of static data. it can only access the least significant word (lsw) of the program word. 4.3.1 addressing program space since the address ranges for the data and program spaces are 16 and 24 bits, respectively, a method is needed to create a 23-bit or 24-bit program address from 16-bit data registers. the solution depends on the interface method to be used. for table operations, the 8-bit table memory page address register (tblpag) is used to define a 32k word region within the program space. this is concatenated with a 16-bit ea to arrive at a full 24-bit program space address. in this format, the most significant bit (msb) of tblpag is used to determine if the operation occurs in the user memory (tblpag<7> = 0 ) or the configuration memory (tblpag<7> = 1 ). for remapping operations, the 8-bit program space visibility page address register (psvpag) is used to define a 16k word page in the program space. when the msb of the ea is 1 , psvpag is concatenated with the lower 15 bits of the ea to form a 23-bit program space address. unlike the table operations, this limits remapping operations strictly to the user memory area. see table 4-35 and figure 4-5 to know how the pro- gram ea is created for table operations and remapping accesses from the data ea. here, p<23:0> refers to a program space word, whereas d<15:0> refers to a data space word. note: a pc push during exception processing will concatenate the srl register to the msb of the pc prior to the push. note: a write to the splim register should not be immediately followed by an indirect read operation using w15. pc<15:0> 000000000 0 15 w15 (before call ) w15 (after call ) stack grows towards higher address 0000h pc<22:16> pop : [--w15] push : [w15++] downloaded from: http:///
pic24fv16km204 family ds30003030b-page 64 ? 2013 microchip technology inc. table 4-35: program space address construction figure 4-5: data access from program space address generation access type access space program space address <23> <22:16> <15> <14:1> <0> instruction access (code execution) user 0 pc<22:1> 0 0xx xxxx xxxx xxxx xxxx xxx0 tblrd/tblwt (byte/word read/write) user tblpag<7:0> data ea<15:0> 0xxx xxxx xxxx xxxx xxxx xxxx configuration tblpag<7:0> data ea<15:0> 1xxx xxxx xxxx xxxx xxxx xxxx program space visibility (block remap/read) user 0 psvpag<7:0> ( 2 ) data ea<14:0> ( 1 ) 0 xxxx xxxx xxx xxxx xxxx xxxx note 1: data ea<15> is always 1 in this case, but is not used in calculating the program space address. bit 15 of the address is psvpag<0>. 2: psvpag can have only two values ( 00 to access program memory and ff to access data eeprom) on the pic24f16km family. 0 program counter 23 bits 1 psvpag 8 bits ea 15 bits program counter (1) select tblpag 8 bits ea 16 bits byte select 0 0 1/0 user/configuration table operations (2) program space visibility (1) space select 24 bits 23 bits (remapping) 1/0 0 note 1: the lsb of program space addr esses is always fixed as 0 in order to maintain word alignment of data in the program and data spaces. 2: table operations are not required to be word-aligned. t able read operations are permi tted in the configuration memory space. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 65 pic24fv16km204 family 4.3.2 data access from program memory and data eeprom memory using table instructions the tblrdl and tblwtl instructions offer a direct method of reading or writing the lower word of any address within the program memory without going through data space. it also offers a direct method of reading or writing a word of any address within data eeprom memory. the tblrdh and tblwth instruc- tions are the only method to read or write the upper 8 bits of a program space word as data. the pc is incremented by 2 for each successive 24-bit program word. this allows program memory addresses to directly map to data space addresses. program memory can thus be regarded as two 16-bit, word-wide address spaces, residing side by side, each with the same address range. tblrdl and tblwtl access the space which contains the least significant data word, and tblrdh and tblwth access the space which contains the upper data byte. two table instructions are provided to move byte or word-sized (16-bit) data to and from program space. both function as either byte or word operations. 1. tblrdl (table read low): in word mode, it maps the lower word of the program space location (p<15:0>) to a data address (d<15:0>). in byte mode, either the upper or lower byte of the lower program word is mapped to the lower byte of a data address. the upper byte is selected when byte select is 1 ; the lower byte is selected when it is 0 . 2. tblrdh (table read high): in word mode, it maps the entire upper word of a program address (p<23:16>) to a data address. note that d<15:8>, the phantom byte, will always be 0 . in byte mode, it maps the upper or lower byte of the program word to d<7:0> of the data address, as above. note that the data will always be 0 when the upper phantom byte is selected (byte select = 1 ). in a similar fashion, two table instructions, tblwth and tblwtl , are used to write individual bytes or words to a program space address. the details of their operation are explained in section 5.0 flash program memory . for all table operations, the area of program memory space to be accessed is determined by the table memory page address register (tblpag). tblpag covers the entire program memory space of the device, including user and configuration spaces. when tblpag<7> = 0 , the table page is located in the user memory space. when tblpag<7> = 1 , the page is located in configuration space. figure 4-6: accessing program memory with table instructions note: the tblrdh and tblwth instructions are not used while accessing data eeprom memory. note: only table read operations will execute in the configuration memory space, and only then, in implemented areas, such as the device id. table write operations are not allowed. 0 8 16 23 0000000000000000 00000000 00000000 phantom byte tblrdh.b (wn<0> = 0 ) tblrdl.w tblrdl.b (wn<0> = 1 ) tblrdl.b (wn<0> = 0 ) 23 15 0 tblpag 00 000000h 800000h 002bfeh program space data ea<15:0> the address for the table operation is determined by the data ea within the page defined by the tblpag register. only read operations are provided; write operations are also valid in the user memory area. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 66 ? 2013 microchip technology inc. 4.3.3 reading data from program memory using program space visibility the upper 32 kbytes of data space may optionally be mapped into a 16k word page of the program space. this provides transparent access of stored constant data from the data space without the need to use special instructions (i.e., tblrdl/h ). program space access through the data space occurs if the msb of the data space, ea, is 1 and psv is enabled by setting the psv bit in the cpu control (corcon<2>) register. the location of the program memory space to be mapped into the data space is determined by the program space visibility page address register (psvpag). this 8-bit register defines any one of 256 possible pages of 16k words in program space. in effect, psvpag functions as the upper 8 bits of the program memory address, with the 15 bits of the ea functioning as the lower bits. by incrementing the pc by 2 for each program memory word, the lower 15 bits of data space addresses directly map to the lower 15 bits in the corresponding program space addresses. data reads from this area add an additional cycle to the instruction being executed, since two program memory fetches are required. although each data space address, 8000h and higher, maps directly into a corresponding program memory address (see figure 4-7 ), only the lower 16 bits of the 24-bit program word are used to contain the data. the upper 8 bits of any program space locations used as data should be programmed with 1111 1111 or 0000 0000 to force a nop . this prevents possible issues should the area of code ever be accidentally executed. for operations that use psv and are executed outside a repeat loop, the mov and mov.d instructions will require one instruction cycle in addition to the specified execution time. all other instructions will require two instruction cycles in addition to the specified execution time. for operations that use psv, which are executed inside a repeat loop, there will be some instances that require two instruction cycles in addition to the specified execution time of the instruction: execution in the first iteration execution in the last iteration execution prior to exiting the loop due to an interrupt execution upon re-entering the loop after an interrupt is serviced any other iteration of the repeat loop will allow the instruction accessing data, using psv, to execute in a single cycle. figure 4-7: program spac e visibility operation note: psv access is temporarily disabled during table reads/writes. 23 15 0 psvpag data space program space 0000h 8000h ffffh 00 000000h 800000h 002bfeh when corcon<2> = 1 and ea<15> = 1 : psv area the data in the page designated by psvpag is mapped into the upper half of the data memory space.... data ea<14:0> ...while the lower 15 bits of the ea specify an exact address within the psv area. this corresponds exactly to the same lower 15 bits of the actual program space address. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 67 pic24fv16km204 family 5.0 flash program memory the pic24fv16km204 family of devices contains internal flash program memory for storing and execut- ing application code. the memory is readable, writable and erasable when operating with v dd over 1.8v. flash memory can be programmed in three ways: in-circuit serial programming? (icsp?) run-time self-programming (rtsp) enhanced in-circuit serial programming (enhanced icsp) icsp allows a pic24fxxxxx device to be serially pro- grammed while in the end application circuit. this is simply done with two lines for the programming clock and programming data (which are named pgecx and pgedx, respectively), and three other lines for power (v dd ), ground (v ss ) and master clear/program mode entry voltage (mclr /v pp ). this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware or custom firmware to be programmed. run-time self-programming (rtsp) is accomplished using tblrd (table read) and tblwt (table write) instructions. with rtsp, the user may write program memory data in blocks of 32 instructions (96 bytes) at a time, and erase program memory in blocks of 32, 64 and 128 instructions (96,192 and 384 bytes) at a time. the nvmop<1:0> (nvmcon<1:0>) bits decide the erase block size. 5.1 table instructions and flash programming regardless of the method used, flash memory programming is done with the table read and write instructions. these allow direct read and write access to the program memory space from the data memory while the device is in normal operating mode. the 24-bit target address in the program memory is formed using the tblpag<7:0> bits and the effective address (ea) from a w register, specified in the table instruction, as depicted in figure 5-1 . the tblrdl and the tblwtl instructions are used to read or write to bits<15:0> of program memory. tblrdl and tblwtl can access program memory in both word and byte modes. the tblrdh and tblwth instructions are used to read or write to bits<23:16> of program memory. tblrdh and tblwth can also access program memory in word or byte mode. figure 5-1: addressing for table registers note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on flash programming, refer to the pic24f family reference manual , program memory (ds39715). 24 bits program tblpag reg 8 bits 16 bits using byte 24-bit ea 1/0 select table instruction counter using user/configuration space select working reg ea 0 program counter 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 68 ? 2013 microchip technology inc. 5.2 rtsp operation the pic24f flash program memory array is organized into rows of 32 instructions or 96 bytes. rtsp allows the user to erase blocks of 1 row, 2 rows and 4 rows (32, 64 and 128 instructions) at a time, and to program one row at a time. it is also possible to program single words. the 1-row (96 bytes), 2-row (192 bytes) and 4-row (384 bytes) erase blocks, and single row write block (96 bytes) are edge-aligned, from the beginning of program memory. when data is written to program memory using tblwt instructions, the data is not written directly to memory. instead, data written using table writes is stored in holding latches until the programming sequence is executed. any number of tblwt instructions can be executed and a write will be successfully performed. however, 32 tblwt instructions are required to write the full row of memory. the basic sequence for rtsp programming is to set up a table pointer, then do a series of tblwt instructions to load the buffers. programming is performed by setting the control bits in the nvmcon register. data can be loaded in any order and the holding regis- ters can be written to multiple times before performing a write operation. subsequent writes, however, will wipe out any previous writes. all of the table write operations are single-word writes (two instruction cycles), because only the buffers are writ- ten. a programming cycle is required for programming each row. 5.3 enhanced in-circuit serial programming enhanced icsp uses an on-board bootloader, known as the program executive (pe), to manage the pro- gramming process. using an spi data frame format, the program executive can erase, program and verify program memory. for more information on enhanced icsp, see the device programming specification. 5.4 control registers there are two sfrs used to read and write the program flash memory: nvmcon and nvmkey. the nvmcon register ( register 5-1 ) controls the blocks that need to be erased, which memory type is to be programmed and when the programming cycle starts. nvmkey is a write-only register that is used for write protection. to start a pr ogramming or erase sequence, the user must consecutively write 55h and aah to the nvmkey register. refer to section 5.5 programming operations for further details. 5.5 programming operations a complete programming sequence is necessary for programming or erasing the internal flash in rtsp mode. during a programming or erase operation, the processor stalls (waits) until the operation is finished. setting the wr bit (nvmcon<15>) starts the operation and the wr bit is automatically cleared when the operation is finished. note: writing to a location multiple times, without erasing it, is not recommended. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 69 pic24fv16km204 family register 5-1: nvmcon: flash memory control register r/so-0, hc r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 wr wren wrerr pgmonly ( 4 ) bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 erase nvmop5 ( 1 ) nvmop4 ( 1 ) nvmop3 ( 1 ) nvmop2 ( 1 ) nvmop1 ( 1 ) nvmop0 ( 1 ) bit 7 bit 0 legend: so = settable only bit hc = hardware clearable bit -n = value at por 1 = bit is set r = readable bit w = writable bit 0 = bit is cleared x = bit is unknown u = unimplemented bit, read as 0 bit 15 wr: write control bit 1 = initiates a flash memory program or erase operation; the operation is self-timed and the bit is cleared by hardware once the operation is complete 0 = program or erase operation is complete and inactive bit 14 wren: write enable bit 1 = enables flash program/erase operations 0 = inhibits flash program/erase operations bit 13 wrerr: write sequence error flag bit 1 = an improper program or erase s equence attempt, or termination has occurred (bit is set automatically on any set attempt of the wr bit) 0 = the program or erase operation completed normally bit 12 pgmonly: program only enable bit ( 4 ) bit 11-7 unimplemented: read as 0 bit 6 erase: erase/program enable bit 1 = performs the erase operation specified by the nvmop<5:0> bits on the next wr command 0 = performs the program operation specified by the nvmop<5:0> bits on the next wr command bit 5-0 nvmop<5:0>: programming operation command byte bits ( 1 ) erase operations (when erase bit is 1 ): 1010xx = erase entire boot block (including code-protected boot block) ( 2 ) 1001xx = erase entire memory (including boot block, configuration block, general block) ( 2 ) 011010 = erase 4 rows of flash memory ( 3 ) 011001 = erase 2 rows of flash memory ( 3 ) 011000 = erase 1 row of flash memory ( 3 ) 0101xx = erase entire configuration block (except code protection bits) 0100xx = erase entire data eeprom ( 4 ) 0011xx = erase entire general memory block programming operations 0001xx = write 1 row of flash memory (when erase bit is 0 ) ( 3 ) note 1: all other combinations of nvmop<5:0> are no operation. 2: available in icsp? mode only. refer to the device programming specification. 3: the address in the table pointer decides which rows will be erased. 4: this bit is used only while accessing data eeprom. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 70 ? 2013 microchip technology inc. 5.5.1 programming algorithm for flash program memory the user can program one row of flash program memory at a time by erasing the programmable row. the general process is: 1. read a row of program memory (32 instructions) and store in data ram. 2. update the program data in ram with the desired new data. 3. erase a row (see example 5-1 ): a) set the nvmopx bits (nvmcon<5:0>) to 011000 to configure for row erase. set the erase (nvmcon<6>) and wren (nvmcon<14>) bits. b) write the starting address of the block to be erased into the tblpag and w registers. c) write 55h to nvmkey. d) write aah to nvmkey. e) set the wr bit (nvmcon<15>). the erase cycle begins and the cpu stalls for the duration of the erase cycle. when the erase is done, the wr bit is cleared automatically. 4. write the first 32 instructions from data ram into the program memory buffers (see example 5-1 ). 5. write the program block to flash memory: a) set the nvmopx bits to 000100 to configure for row programming. clear the erase bit and set the wren bit. b) write 55h to nvmkey. c) write aah to nvmkey. d) set the wr bit. the programming cycle begins and the cpu stalls for the duration of the write cycle. when the write to flash memory is done, the wr bit is cleared automatically. for protection against accidental operations, the write initiate sequence for nvmkey must be used to allow any erase or program operation to proceed. after the programming command has been executed, the user must wait for the programming time until programming is complete. the two instructions following the start of the programming sequence should be nop s, as displayed in example 5-5 . example 5-1: erasing a program memo ry row C assembly language code example 5-2: erasing a program me mory row C c language code ; set up nvmcon for row erase operation mov #0x4058, w0 ; mov w0, nvmcon ; initialize nvmcon ; init pointer to row to be erased mov #tblpage(prog_addr), w0 ; mov w0, tblpag ; initialize pm page boundary sfr mov #tbloffset(prog_addr), w0 ; initialize in-page ea[15:0] pointer tblwtl w0, [w0] ; set base address of erase block disi #5 ; block all interrupts for next 5 instructions mov #0x55, w0 mov w0, nvmkey ; write the 55 key mov #0xaa, w1 ; mov w1, nvmkey ; write the aa key bset nvmcon, #wr ; start the erase sequence nop ; insert two nops after the erase nop ; command is asserted // c example using mplab c30 int __attribute__ ((space(auto_psv))) progaddr = 0x1234; // variable located in pgm memory, declare d as a // global variable unsigned int offset; //set up pointer to the first memory location to be written tblpag = __builtin_tblpage(&progaddr); // initialize pm page boundary sfr offset = __ builtin_tbloffset(&progaddr); // initialize lower word of address __builtin_tblwtl(offset, 0x0000); // set base address of erase block // with dummy latch write nvmcon = 0x4058; // initialize nvmcon asm("disi #5"); // block all interrupts for next 5 instructions __builtin_write_nvm(); // c30 function to perform unlock // sequence and set wr downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 71 pic24fv16km204 family example 5-3: loading the write bu ffers C assembly language code example 5-4: loading the write buffers C c language code ; set up nvmcon for row programming operations mov #0x4004, w0 ; mov w0, nvmcon ; initialize nvmcon ; set up a pointer to the first program memory location to be written ; program memory selected, and writes enabled mov #0x0000, w0 ; mov w0, tblpag ; initialize pm page boundary sfr mov #0x1500, w0 ; an example program memory address ; perform the tblwt instructions to write the latches ; 0th_program_word mov #low_word_0, w2 ; mov #high_byte_0, w3 ; tblwtl w2, [w0] ; write pm low word into program latch tblwth w3, [w0++] ; write pm high byte into program latch ; 1st_program_word mov #low_word_1, w2 ; mov #high_byte_1, w3 ; tblwtl w2, [w0] ; write pm low word into program latch tblwth w3, [w0++] ; write pm high byte into program latch ; 2nd_program_word mov #low_word_2, w2 ; mov #high_byte_2, w3 ; tblwtl w2, [w0] ; write pm low word into program latch tblwth w3, [w0++] ; write pm high byte into program latch ; 32nd_program_word mov #low_word_31, w2 ; mov #high_byte_31, w3 ; tblwtl w2, [w0] ; write pm low word into program latch tblwth w3, [w0] ; write pm high byte into program latch // c example using mplab c30 #define num_instruction_per_row 64 int __attribute__ ((space(auto_psv))) progaddr = 0x1234 // variable located in pgm memory unsigned int offset; unsigned int i; unsigned int progdata[2*num_instruction_per_row]; // buffer of data to write //set up nvmcon for row programming nvmcon = 0x4004; // initialize nvmcon //set up pointer to the first memory location to be written tblpag = __builtin_tblpage(&progaddr); // initialize pm page boundary sfr offset = __ builtin_tbloffset(&progaddr); // initialize lower word of address //perform tblwt instructions to write necessary number of latches for(i=0; i < 2*num_instruction_per_row; i++) { __builtin_tblwtl(offset, progdata[i++]); // write to address low word __builtin_tblwth(offset, progdata[i]); // write to upper byte offset = offset + 2; // increment address } downloaded from: http:///
pic24fv16km204 family ds30003030b-page 72 ? 2013 microchip technology inc. example 5-5: initiating a programming sequence C assembly language code example 5-6: initiating a programmi ng sequence C c language code disi #5 ; block all interrupts for next 5 instructions mov #0x55, w0 mov w0, nvmkey ; write the 55 key mov #0xaa, w1 ; mov w1, nvmkey ; write the aa key bset nvmcon, #wr ; start the erase sequence nop ; 2 nops required after setting wr nop ; btsc nvmcon, #15 ; wait for the sequence to be completed bra $-2 ; // c example using mplab c30 asm("disi #5"); // block all interrupts for next 5 instructions __builtin_write_nvm(); // perform unlock sequence and set wr downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 73 pic24fv16km204 family 6.0 data eeprom memory the data eeprom memory is a nonvolatile memory (nvm), separate from the program and volatile data ram. data eeprom memory is based on the same flash technology as program memory, and is optimized for both long retention and a higher number of erase/write cycles. the data eeprom is mapped to the top of the user pro- gram memory space, with the top address at program memory address, 7ffe00h to 7fffffh. the size of the data eeprom is 256 words in pic24fxxxxx devices. the data eeprom is organized as 16-bit-wide memory. each word is directly addressable, and is readable and writable during normal operation over the entire v dd range. unlike the flash program memory, normal program execution is not stopped during a data eeprom program or erase operation. the data eeprom programming operations are controlled using the three nvm control registers: nvmcon: nonvolatile memory control register nvmkey: nonvolatile memory key register nvmadr: nonvolatile memory address register 6.1 nvmcon register the nvmcon register ( register 6-1 ) is also the primary control register for data eeprom program/erase operations. the upper byte contains the control bits used to start the program or erase cycle and the flag bit to indicate if the operation was successfully performed. the lower byte of nvmcom configures the type of nvm operation that will be performed. 6.2 nvmkey register the nvmkey is a write-only register that is used to prevent accidental writes or erasures of data eeprom locations. to start any programming or erase sequence, the following instructions must be executed first, in the exact order provided: 1. write 55h to nvmkey. 2. write aah to nvmkey. after this sequence, a write will be allowed to the nvmcon register for one instruction cycle. in most cases, the user will simply need to set the wr bit in the nvmcon register to start the program or erase cycle. interrupts should be disabled during the unlock sequence. the mplab ? c30 c compiler provides a defined library procedure ( builtin_write_nvm ) to perform the unlock sequence. example 6-1 illustrates how the unlock sequence can be performed with in-line assembly. example 6-1: data eeprom unlock sequence note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on data eeprom, refer to the pic24f family reference manual , data eeprom (ds39720). //disable interrupts for 5 instructions asm volatile ("disi #5"); //issue unlock sequence asm volatile ("mov #0x55, w0 \n" "mov w0, nvmkey \n" "mov #0xaa, w1 \n" "mov w1, nvmkey \n"); // perform write/erase operations asm volatile ("bset nvmcon, #wr \n" "nop \n" "nop \n"); downloaded from: http:///
pic24fv16km204 family ds30003030b-page 74 ? 2013 microchip technology inc. register 6-1: nvmcon: nonvolat ile memory control register r/so-0, hc r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 wr wren wrerr pgmonly bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 erase nvmop5 nvmop4 nvmop3 nvmop2 nvmop1 nvmop0 bit 7 bit 0 legend: hc = hardware clearable bit u = unimplemented bit, read as 0 r = readable bit w = writable bit s = settable only bit -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 wr: write control bit (program or erase) 1 = initiates a data eeprom erase or write cycle (can be set, but not cleared in software) 0 = write cycle is complete (cleared automatically by hardware) bit 14 wren: write enable bit (erase or program) 1 = enables an erase or program operation 0 = no operation allowed (device clears this bit on completion of the write/erase operation) bit 13 wrerr: flash error flag bit 1 = a write operation is prematurely terminated (any mclr or wdt reset during programming operation) 0 = the write operation completed successfully bit 12 pgmonly: program only enable bit 1 = write operation is executed without erasing target address(es) first 0 = automatic erase-before-write write operations are preceded automatically by an erase of the target address(es). bit 11-7 unimplemented: read as 0 bit 6 erase: erase operation select bit 1 = performs an erase operation when wr is set 0 = performs a write operation when wr is set bit 5-0 nvmop<5:0>: programming operation command byte bits erase operations (when erase bit is 1 ): 011010 = erase 8 words 011001 = erase 4 words 011000 = erase 1 word 0100xx = erase entire data eeprom programming operations (when erase bit is 0 ): 0001xx = write 1 word downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 75 pic24fv16km204 family 6.3 nvm address register as with flash program memory, the nvm address registers, nvmadru and nvmadr, form the 24-bit effective address (ea) of the selected row or word for data eeprom operations. the nvmadru register is used to hold the upper 8 bits of the ea, while the nvmadr register is used to hold the lower 16 bits of the ea. these registers are not mapped into the special function register (sfr) space; instead, they directly capture the ea<23:0> of the last table write instruction that has been executed and select the data eeprom row to erase. figure 6-1 depicts the program memory ea that is formed for programming and erase operations. like program memory operations, the least significant bit (lsb) of nvmadr is restricted to even addresses. this is because any given address in the data eeprom space consists of only the lower word of the program memory width; the upper word, including the uppermost phantom byte, are unavailable. this means that the lsb of a data eeprom address will always be 0 . similarly, the most significant bit (msb) of nvmadru is always 0 , since all addresses lie in the user program space. figure 6-1: data eeprom addressing with tblpag and nvm address registers 6.4 data eeprom operations the eeprom block is accessed using table read and write operations, similar to those used for program memory. the tblwth and tblrdh instructions are not required for data eeprom operations since the memory is only 16 bits wide (data on the lower address is valid only). the following programming operations can be performed on the data eeprom: erase one, four or eight words bulk erase the entire data eeprom write one word read one word the library procedures are used in the code examples detailed in the following sections. general descriptions of each process are provided for users who are not using the xc16 compiler libraries. 24-bit pm address tblpag nvmadr w register ea 7fh xxxxh 0 0 nvmadru note 1: unexpected results will be obtained if the user attempts to read the eeprom while a programming or erase operation is underway. 2: the xc16 c compiler includes library procedures to automatically perform the table read and table write operations, manage the table pointer and write buf- fers, and unlock and initiate memory write sequences. this eliminates the need to create assembler macros or time critical routines in c for each application. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 76 ? 2013 microchip technology inc. 6.4.1 erase data eeprom the data eeprom can be fully erased, or can be partially erased, at three different sizes: one word, four words or eight words. the bits, nvmop<1:0> (nvmcon<1:0>), decide the number of words to be erased. to erase partially from the data eeprom, the following sequence must be followed: 1. configure nvmcon to erase the required number of words: one, four or eight. 2. load tblpag and wreg with the eeprom address to be erased. 3. clear the nvmif status bit and enable the nvm interrupt (optional). 4. write the key sequence to nvmkey. 5. set the wr bit to begin the erase cycle. 6. either poll the wr bit or wait for the nvm interrupt (nvmif is set). a typical erase sequence is provided in example 6-2 . this example shows how to do a one-word erase. similarly, a four-word erase and an eight-word erase can be done. this example uses c library procedures to manage the table pointer ( builtin_tblpage and builtin_tbloffset ) and the erase page pointer ( builtin_tblwtl ). the memory unlock sequence ( builtin_write_nvm ) also sets the wr bit to initiate the operation and returns control when complete. example 6-2: single-word erase int __attribute__ ((space(eedata))) eedata = 0x1234; /*-------------------------------------------------------------------------------------------- the variable eedata must be a global variable declared outside of any method the code following this comment can be written inside the method that will execute the erase ---------------------------------------------------------------------------------------------- */ unsigned int offset; // set up nvmcon to erase one word of data eeprom nvmcon = 0x4058; // set up a pointer to the eeprom location to be erased tblpag = __builtin_tblpage(&eedata); // initialize ee data page pointer offset = __builtin_tbloffset(&eedata); // initizlize lower word of address __builtin_tblwtl(offset, 0); // write eeprom data to write latch asm volatile ("disi #5"); // disable interrupts for 5 instructions __builtin_write_nvm(); // issue unlock sequence & start write cycle while(nvmconbits.wr=1); // optional: poll wr bit to wait for // write sequence to complete downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 77 pic24fv16km204 family 6.4.1.1 data eeprom bulk erase to erase the entire data eeprom (bulk erase), the address registers do not need to be configured because this operation affects the entire data eeprom. the following sequence helps in performing a bulk erase: 1. configure nvmcon to bulk erase mode. 2. clear the nvmif status bit and enable the nvm interrupt (optional). 3. write the key sequence to nvmkey. 4. set the wr bit to begin the erase cycle. 5. either poll the wr bit or wait for the nvm interrupt (nvmif is set). a typical bulk erase sequence is provided in example 6-3 . 6.4.2 single-word write to write a single word in the data eeprom, the following sequence must be followed: 1. erase one data eeprom word (as mentioned in the previous section) if the pgmonly bit (nvmcon<12>) is set to 1 . 2. write the data word into the data eeprom latch. 3. program the data word into the eeprom: - configure the nvmcon register to program one eeprom word (nvmcon<5:0> = 0001xx ). - clear the nvmif status bit and enable the nvm interrupt (optional). - write the key sequence to nvmkey. - set the wr bit to begin the erase cycle. - either poll the wr bit or wait for the nvm interrupt (nvmif is set). - to get cleared, wait until nvmif is set. a typical single-word write sequence is provided in example 6-4 . example 6-3: data eeprom bulk erase example 6-4: single-word write to data eeprom // set up nvmcon to bulk erase the data eeprom nvmcon = 0x4050; // disable interrupts for 5 instructions asm volatile ("disi #5"); // issue unlock sequence and start erase cycle __builtin_write_nvm(); int __attribute__ ((space(eedata))) eedata = 0x1234; int newdata; // new data to write to eeprom /*--------------------------------------------------------------------------------------------- the variable eedata must be a global variable declared outside of any method the code following this comment can be written inside the method that will execute the write ----------------------------------------------------------------------------------------------- */ unsigned int offset; // set up nvmcon to erase one word of data eeprom nvmcon = 0x4004; // set up a pointer to the eeprom location to be erased tblpag = __builtin_tblpage(&eedata); // initialize ee data page pointer offset = __builtin_tbloffset(&eedata); // initizlize lower word of address __builtin_tblwtl(offset, newdata); // write eeprom data to write latch asm volatile ("disi #5"); // disable interrupts for 5 instructions __builtin_write_nvm(); // issue unlock sequence & start write cycle while(nvmconbits.wr=1); // optional: poll wr bit to wait for // write sequence to complete downloaded from: http:///
pic24fv16km204 family ds30003030b-page 78 ? 2013 microchip technology inc. 6.4.3 reading the data eeprom to read a word from data eeprom, the table read instruction is used. since the eeprom array is only 16 bits wide, only the tblrdl instruction is needed. the read operation is performed by loading tblpag and wreg with the address of the eeprom location, followed by a tblrdl instruction. a typical read sequence, using the table pointer management ( builtin_tblpage and builtin_tbloffset ) and table read ( builtin_tblrdl ) procedures from the c30 compiler library, is provided in example 6-5 . program space visibility (psv) can also be used to read locations in the data eeprom. example 6-5: reading the data eeprom using the tblrd command int __attribute__ ((space(eedata))) eedata = 0x1234; int data; // data read from eeprom /*-------------------------------------------------------------------------------------------- the variable eedata must be a global variable declared outside of any method the code following this comment can be written inside the method that will execute the read ---------------------------------------------------------------------------------------------- */ unsigned int offset; // set up a pointer to the eeprom location to be erased tblpag = __builtin_tblpage(&eedata); // initialize ee data page pointer offset = __builtin_tbloffset(&eedata); // initizlize lower word of address data = __builtin_tblrdl(offset); // write eeprom data to write latch downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 79 pic24fv16km204 family 7.0 resets the reset module combines all reset sources and controls the device master reset signal, sysrst . the following is a list of device reset sources: por: power-on reset mclr : pin reset swr: reset instruction wdtr: watchdog timer reset bor: brown-out reset lpbor: low-power bor trapr: trap conflict reset iopuwr: illegal opcode reset uwr: uninitialized w register reset a simplified block diagram of the reset module is shown in figure 7-1 . any active source of reset will make the sysrst signal active. many registers associated with the cpu and peripherals are forced to a known reset state. most registers are unaffected by a reset; their status is unknown on power-on reset (por) and unchanged by all other resets. all types of device reset will set a corresponding status bit in the rcon register to indicate the type of reset (see register 7-1 ). a power-on reset will clear all bits except for the bor and por bits (rcon<1:0>) which are set. the user may set or clear any bit at any time during code execution. the rcon bits only serve as status bits. setting a particular reset status bit in software will not cause a device reset to occur. the rcon register also has other bits associated with the watchdog timer (wdt) and device power-saving states. the function of these bits is discussed in other sections of this manual. figure 7-1: reset sy stem block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on resets, refer to the pic24f family reference manual , reset with programmable brown-out reset (ds39728). note: refer to the specific peripheral or section 3.0 cpu of this data sheet for register reset states. note: the status bits in the rcon register should be cleared after they are read so that the next rcon register value after a device reset will be meaningful. mclr v dd v dd rise detect por sleep or idle brown-out reset reset instruction wdt module glitch filter bor trap conflict illegal opcode uninitialized w register sysrst boren<1:0> 0001 10 11 0 sboren sleep 1 configuration mismatch enable voltage regulator (rcon<13>) pic24fv16kmxxx (only) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 80 ? 2013 microchip technology inc. register 7-1: rcon: re set control register ( 1 ) r/w-0, hs r/w-0, hs r/w-0 r/w-0 u-0 u-0 r/w-0 r/w-0 trapr iopuwr sboren reten ( 3 ) c mp m s l p bit 15 bit 8 r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs r/w-1, hs r/w-1, hs extr swr swdten ( 2 ) wdto sleep idle bor por bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 trapr: trap reset flag bit 1 = a trap conflict reset has occurred 0 = a trap conflict reset has not occurred bit 14 iopuwr: illegal opcode or uninitialized w access reset flag bit 1 = an illegal opcode detection, an illegal address mode or uninitialized w register used as an address pointer caused a reset 0 = an illegal opcode or uninitialized w reset has not occurred bit 13 sboren: software enable/disable of bor bit 1 = bor is turned on in software 0 = bor is turned off in software bit 12 reten: retention sleep mode ( 3 ) 1 = regulated voltage supply provided by the retention regulator (retreg) during sleep 0 = regulated voltage supply provided by the main voltage regulator (vreg) during sleep bit 11-10 unimplemented: read as 0 bit 9 cm: configuration word mismatch reset flag bit 1 = a configuration word mismatch reset has occurred 0 = a configuration word mismatch reset has not occurred bit 8 pmslp: program memory power during sleep bit 1 = program memory bias voltage remains powered during sleep 0 = program memory bias voltage is powered down during sleep and the voltage regulator enters standby mode bit 7 extr: external reset (mclr ) pin bit 1 = a master clear (pin) reset has occurred 0 = a master clear (pin) reset has not occurred bit 6 swr: software reset (instruction) flag bit 1 = a reset instruction has been executed 0 = a reset instruction has not been executed bit 5 swdten: software enable/disable of wdt bit ( 2 ) 1 = wdt is enabled 0 = wdt is disabled note 1: all of the reset status bits may be set or cleared in software. setting one of these bits in software do es not cause a device reset. 2: if the fwdten<1:0> configuration bits are 11 (unprogrammed), the wdt is always enabled regardless of the swdten bit setting. 3: this is implemented on pic24fv16kmxxx parts only; not used on pic24f16kmxxx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 81 pic24fv16km204 family table 7-1: reset flag bit operation bit 4 wdto: watchdog timer time-out flag bit 1 = wdt time-out has occurred 0 = wdt time-out has not occurred bit 3 sleep: wake-up from sleep flag bit 1 = device has been in sleep mode 0 = device has not been in sleep mode bit 2 idle: wake-up from idle flag bit 1 = device has been in idle mode 0 = device has not been in idle mode bit 1 bor: brown-out reset flag bit 1 = a brown-out reset has occurred (the bor is also set after a por) 0 = a brown-out reset has not occurred bit 0 por: power-on reset flag bit 1 = a power-on reset has occurred 0 = a power-on reset has not occurred flag bit setting event clearing event trapr (rcon<15>) trap conflict event por iopuwr (rcon<14>) illegal opcode or uninitialized w register access por cm (rcon<9>) configuration mismatch reset por extr (rcon<7>) mclr reset por swr (rcon<6>) reset instruction por wdto (rcon<4>) wdt time-out pwrsav instruction, por sleep (rcon<3>) pwrsav #sleep instruction por idle (rcon<2>) pwrsav #idle instruction por bor (rcon<1>) por, bor por (rcon<0>) por note: all reset flag bits may be set or cleared by the user software. register 7-1: rcon: re set control register ( 1 ) (continued) note 1: all of the reset status bits may be set or cleared in software. setting one of these bits in softwa re does not cause a device reset. 2: if the fwdten<1:0> configuration bits are 11 (unprogrammed), the wdt is always enabled regardless of the swdten bit setting. 3: this is implemented on pic24fv16kmxxx parts only; not used on pic24f16kmxxx devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 82 ? 2013 microchip technology inc. 7.1 clock source selection at reset if clock switching is enabled, the system clock source at device reset is chosen, as shown in table 7-2 . if clock switching is disabled, the system clock source is always selected according to the oscillator configuration bits. for more information, see section 9.0 oscillator configuration . table 7-2: oscillator selection vs. type of reset (clock switching enabled) 7.2 device reset times the reset times for various types of device reset are summarized in table 7-3 . note that the system reset signal, sysrst , is released after the por and pwrt delay times expire. the time at which the device actually begins to execute code will also depend on the system oscillator delays, which include the oscillator start-up timer (ost) and the pll lock time. the ost and pll lock times occur in parallel with the applicable sysrst delay times. the fscm delay determines the time at which the fscm begins to monitor the system clock source after the sysrst signal is released. table 7-3: reset delay times for various device resets reset type clock source determinant por fnosc<2:0> configuration bits (foscsel<2:0>) bor mclr cosc<2:0> control bits (osccon<14:12>) wdto swr reset type clock source sysrst delay system clock delay notes por ( 6 ) ec t por + t pwrt 1 , 2 frc, frcdiv t por + t pwrt t frc 1 , 2 , 3 lprc t por + t pwrt t lprc 1 , 2 , 3 ecpll t por + t pwrt t lock 1 , 2 , 4 frcpll t por + t pwrt t frc + t lock 1 , 2 , 3 , 4 xt, hs, sosc t por + t pwrt t ost 1 , 2 , 5 xtpll, hspll t por + t pwrt t ost + t lock 1 , 2 , 4 , 5 bor ec t pwrt 2 frc, frcdiv t pwrt t frc 2 , 3 lprc t pwrt t lprc 2 , 3 ecpll t pwrt t lock 2 , 4 frcpll t pwrt t frc + t lock 2 , 3 , 4 xt, hs, sosc t pwrt t ost 2 , 5 xtpll, hspll t pwrt t frc + t lock 2 , 3 , 4 all others any clock none note 1: t por = power-on reset delay. 2: t pwrt = 64 ms nominal if the power-up timer is enabled; otherwise, it is zero. 3: t frc and t lprc = rc oscillator start-up times. 4: t lock = pll lock time. 5: t ost = oscillator start-up timer (ost). a 10-bit counter waits 1024 oscillator periods before releasing the oscillator clock to the system. 6: if two-speed start-up is enabled, regardless of the primary oscillator selected, the device starts with frc, and in such cases, frc start-up time is valid. note: for detailed operating frequency and timing specifications, see section 27.0 electrical characteristics . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 83 pic24fv16km204 family 7.2.1 por and long oscillator start-up times the oscillator start-up circuitry and its associated delay timers are not linked to the device reset delays that occur at power-up. some crystal circuits (especially low-frequency crystals) will have a relatively long start-up time. therefore, one or more of the following conditions is possible after sysrst is released: the oscillator circuit has not begun to oscillate. the oscillator start-up timer (ost) has not expired (if a crystal oscillator is used). the pll has not achieved a lock (if pll is used). the device will not begin to execute code until a valid clock source has been released to the system. therefore, the oscillator and pll start-up delays must be considered when the reset delay time must be known. 7.2.2 fail-safe clock monitor (fscm) and device resets if the fscm is enabled, it will begin to monitor the system clock source when sysrst is released. if a valid clock source is not available at this time, the device will automatically switch to the frc oscillator and the user can switch to the desired crystal oscillator in the trap service routine (tsr). 7.3 special function register reset states most of the special function registers (sfrs) associated with the pic24f cpu and peripherals are reset to a particular value at a device reset. the sfrs are grouped by their peripheral or cpu function and their reset values are specified in each section of this manual. the reset value for each sfr does not depend on the type of reset, with the exception of four registers. the reset value for the reset control register, rcon, will depend on the type of device reset. the reset value for the oscillator control register, osccon, will depend on the type of reset and the programmed values of the fnoscx bits in the flash configuration word (foscsel<2:0>); see tab le 7 - 2 . the rcfgcal and nvmcon registers are only affected by a por. 7.4 brown-out reset (bor) the pic24fxxxxx family devices implement a bor circuit, which provides the user several configuration and power-saving options. the bor is controlled by the borv<1:0> and boren<1:0> configuration bits (fpor<6:5,1:0>). there are a total of four bor configurations, which are provided in tab l e 7 - 3 . the bor threshold is set by the borv<1:0> bits. if bor is enabled (any values of boren<1:0>, except 00 ), any drop of v dd below the set threshold point will reset the device. the chip will remain in bor until v dd rises above the threshold. if the power-up timer is enabled, it will be invoked after v dd rises above the threshold. then, it will keep the chip in reset for an additional time delay, t pwrt , if v dd drops below the threshold while the power-up timer is running. the chip goes back into a bor and the power-up timer will be initialized. once v dd rises above the threshold, the power-up timer will execute the additional time delay. bor and the power-up timer (pwrt) are inde- pendently configured. enabling the brown-out reset does not automatically enable the pwrt. 7.4.1 low-power bor (lpbor) the low-power bor is an alternate setting for the bor, designed to consume minimal power. in lpbor mode, borv<1:0> (fpor<6:5>) = 00 . the bor trip point is approximately 2.0v. due to the low current consumption, the accuracy of the lpbor mode can vary. unlike the other bor modes, lpbor mode will not cause a device reset when v dd drops below the trip point. instead, it re-arms the por circuit to ensure that the device will reset properly in the event that v dd continues to drop below the minimum operating voltage. the device will continue to execute code when v dd is below the level of the lpbor trip point. a device that requires falling edge bor protection to prevent code from improperly executing should use one of the other bor voltage settings. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 84 ? 2013 microchip technology inc. 7.4.2 software enabled bor when boren<1:0> = 01 , the bor can be enabled or disabled by the user in software. this is done with the control bit, sboren (rcon<13>). setting sboren enables the bor to function as previously described. clearing the sboren disables the bor entirely. the sboren bit operates only in this mode; otherwise, it is read as 0 . placing bor under software control gives the user the additional flexibility of tailoring the application to its environment without having to reprogram the device to change the bor configuration. it also allows the user to tailor the incremental current that the bor consumes. while the bor current is typically very small, it may have some impact in low-power applications. 7.4.3 detecting bor when bor is enabled, the bor bit (rcon<1>) is always reset to 1 on any bor or por event. this makes it difficult to determine if a bor event has occurred just by reading the state of bor alone. a more reliable method is to simultaneously check the state of both por and bor. this assumes that the por and bor bits are reset to 0 in the software immediately after any por event. if the bor bit is 1 while por is 0 , it can be reliably assumed that a bor event has occurred. 7.4.4 disabling bor in sleep mode when boren<1:0> = 10 , bor remains under hardware control and operates as previously described. however, whenever the device enters sleep mode, bor is automatically disabled. when the device returns to any other operating mode, bor is automatically re-enabled. this mode allows for applications to recover from brown-out situations, while actively executing code, when the device requires bor protection the most. at the same time, it saves additional power in sleep mode by eliminating the small incremental bor current. note: even when the bor is under software con- trol, the brown-out reset voltage level is still set by the borv<1:0> configuration bits; it can not be changed in software. note: bor levels differ depending on device type; pic24fv16km204 devices are at different levels than those of pic24f16km204 devices. see section 27.0 electrical characteristics for bor voltage levels. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 85 pic24fv16km204 family 8.0 interrupt controller the pic24f interrupt controller reduces the numerous peripheral interrupt request signals to a single interrupt request signal to the cpu. it has the following features: up to eight processor exceptions and software traps seven user-selectable priority levels interrupt vector table (ivt) with up to 118 vectors unique vector for each interrupt or exception source fixed priority within a specified user priority level alternate interrupt vector table (aivt) for debug support fixed interrupt entry and return latencies 8.1 interrupt vector table (ivt) the ivt is shown in figure 8-1 . the ivt resides in the program memory, starting at location, 000004h. the ivt contains 126 vectors, consisting of eight non-maskable trap vectors, plus up to 118 sources of interrupt. in general, each interrupt source has its own vector. each interrupt vector contains a 24-bit-wide address. the value programmed into each interrupt vector location is the starting address of the associated interrupt service routine (isr). interrupt vectors are prioritized in terms of their natural priority; this is linked to their position in the vector table. all other things being equal, lower addresses have a higher natural priority. for example, the interrupt associated with vector 0 will take priority over interrupts at any other vector address. pic24fv16km204 family devices implement non-maskable traps and unique interrupts; these are summarized in ta b l e 8 - 1 . 8.1.1 alternate interrupt vector ta b l e (a i v t ) the alternate interrupt vector table (aivt) is located after the ivt, as shown in figure 8-1 . access to the aivt is provided by the altivt control bit (intcon2<15>). if the altivt bit is set, all interrupt and exception processes will use the alternate vectors instead of the default vectors. the alternate vectors are organized in the same manner as the default vectors. the aivt supports emulation and debugging efforts by providing a means to switch between an application and a support environment without requiring the inter- rupt vectors to be reprogrammed. this feature also enables switching between applications for evaluation of different software algorithms at run time. if the aivt is not needed, the aivt should be programmed with the same addresses used in the ivt. 8.2 reset sequence a device reset is not a true exception, because the interrupt controller is not involved in the reset process. the pic24f devices clear their registers in response to a reset, which forces the program counter (pc) to zero. the microcontroller then begins program execution at location, 000000h. the user programs a goto instruction at the reset address, which redirects the program execution to the appropriate start-up routine. note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive refer- ence source. for more information on the interrupt controller, refer to the pic24f family reference manual , interrupts (ds39707). note: any unimplemented or unused vector locations in the ivt and aivt should be programmed with the address of a default interrupt handler routine that contains a reset instruction. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 86 ? 2013 microchip technology inc. figure 8-1: pic24f interrupt vector table reset C goto instruction 000000h reset C goto address 000002h reserved 000004h oscillator fail trap vector address error trap vector stack error trap vector math error trap vector reserved reserved reserved interrupt vector 0 000014h interrupt vector 1 interrupt vector 52 00007ch interrupt vector 53 00007eh interrupt vector 54 000080h interrupt vector 116 0000fch interrupt vector 117 0000feh reserved 000100h reserved 000102h reserved oscillator fail trap vector address error trap vector stack error trap vector math error trap vector reserved reserved reserved interrupt vector 0 000114h interrupt vector 1 interrupt vector 52 00017ch interrupt vector 53 00017eh interrupt vector 54 000180h interrupt vector 116 interrupt vector 117 0001feh start of code 000200h decreasing natural order priority interrupt vector table (ivt) alternate interrupt vector table (aivt) downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 87 pic24fv16km204 family table 8-1: trap vector details vector number ivt address aivt address trap source 0 000004h 000104h reserved 1 000006h 000106h oscillator failure 2 000008h 000108h address error 3 00000ah 00010ah stack error 4 00000ch 00010ch math error 5 00000eh 00010eh reserved 6 000010h 000110h reserved 7 000012h 000112h reserved table 8-2: implemented interrupt vectors interrupt source vector number ivt address aivt address interrupt bit locations flag enable priority adc1 C adc1 convert done 13 00002eh 00012eh ifs0<13> iec0<13> ipc3<6:4> clc1 96 0000d4h 0001d4h ifs6<0> iec6<0> ipc24<2:0> clc2 97 0000d6h 0001d6h ifs6<1> iec6<1> ipc24<6:4> comparator interrupt 18 000038h 000138h ifs1<2> iec1<2> ipc4<10:8> ctmu 77 0000aeh 0001aeh ifs4<13> iec4<13> ipc19<6:4> dac1 C buffer update 78 0000b0h 0001b0h ifs4<14> iec4<14> ipc19<10:8> dac2 C buffer update 79 0000b2h 0001b2h ifs4<15> iec4<15> ipc19<14:12> hlvd C high/low-voltage detect 72 0000a4h 0001a4h ifs4<8> iec4<8> ipc18<2:0> icn C input change notification 19 00003ah 00013ah ifs1<3> iec1<3> ipc4<14:12> int0 C external interrupt 0 0 000014h 000114h ifs0<0> iec0<0> ipc0<2:0> int1 C external interrupt 1 20 00003ch 00013ch ifs1<4> iec1<4> ipc5<2:0> int2 C external interrupt 2 29 00004eh 00014eh ifs1<13> iec1<13> ipc7<6:4> mccp1 C capture/compare 1 000016h 000116h ifs0<1> iec0<1> ipc0<6:4> mccp1 C time base 7 000022h 000122h ifs0<7> iec0<7> ipc1<14:12> mccp2 C capture/compare 2 000018h 000118h ifs0<2> iec0<2> ipc0<10:8> mccp2 C time base 8 000024h 000124h ifs0<8> iec0<8> ipc2<2:0> mccp3 C capture/compare 5 00001eh 00011eh ifs0<5> iec0<5> ipc1<6:4> mccp3 C time base 27 00004ah 00014ah ifs1<11> iec1<11> ipc6<14:12> mssp1 C bus collision interrupt 17 000036h 000136h ifs1<1> iec1<1> ipc4<6:4> mssp1 C i 2 c?/spi interrupt 16 000034h 000134h ifs1<0> iec1<0> ipc4<2:0> mssp2 C bus collision interrupt 50 000078h 000178h ifs3<2> iec3<2> ipc12<10:8> mssp2 C i 2 c/spi interrupt 49 000076h 000176h ifs3<1> iec3<1> ipc12<6:4> nvm C nvm write complete 15 000032h 000132h ifs0<15> iec0<15> ipc3<14:12> rtcc C real-time clock/calendar 62 000090h 000190h ifs3<14> iec3<14> ipc15<10:8> sccp4 C capture/compare 6 000020h 000120h ifs0<6> iec0<6> ipc1<10:8> sccp4 C time base 28 00004ch 00014ch ifs1<12> iec1<12> ipc7<2:0> sccp5 C capture/compare 22 000040h 000140h ifs1<6> iec1<6> ipc5<10:8> sccp5 C time base 41 000066h 000166h ifs2<9> iec2<9> ipc10<6:4> tmr1 C timer1 3 00001ah 00011ah ifs0<3> iec0<3> ipc0<14:12> uart1 error 65 000096h 000196h ifs4<1> iec4<1> ipc16<6:4> uart2 error 66 000098h 000198h ifs4<2> iec4<2> ipc16<10:8> uart1rx C uart1 receiver 11 00002ah 00012ah ifs0<11> iec0<11> ipc2<14:12> uart1tx C uart1 transmitter 12 00002ch 00012ch ifs0<12> iec0<12> ipc3<2:0> uart2rx C uart2 receiver 30 000050h 000150h ifs1<14> iec1<14> ipc7<10:8> uart2tx C uart2 transmitter 31 000052h 000152h ifs1<15> iec1<15> ipc7<14:12> ulpwu C ultra low-power wake-up 80 0000b4h 0001b4h ifs5<0> iec5<0> ipc20<2:0> downloaded from: http:///
pic24fv16km204 family ds30003030b-page 88 ? 2013 microchip technology inc. 8.3 interrupt control and status registers the pic24fv16km204 family of devices implements a total of 33 registers for the interrupt controller: intcon1 intcon2 ifs0 through ifs6 iec0 through iec6 ipc0 through ipc7, ipc10, ipc12, ipc15, ipc16, ipc18 through ipc20 and ipc24 inttreg global interrupt enable (gie) control functions are controlled from intcon1 and intcon2. intcon1 contains the interrupt nesting disable (nstdis) bit, as well as the control and status flags for the processor trap sources. the intcon2 register controls the exter- nal interrupt request signal behavior and the use of the aivt. the ifsx registers maintain all of the interrupt request flags. each source of interrupt has a status bit, which is set by the respective peripherals, or external signal, and is cleared via software. the iecx registers maintain all of the interrupt enable bits. these control bits are used to individually enable interrupts from the peripherals or external signals. the ipcx registers are used to set the interrupt priority level (ipl) for each source of interrupt. each user interrupt source can be assigned to one of eight priority levels. the inttreg register contains the associated interrupt vector number and the new cpu interrupt priority level, which are latched into the vector number (vecnum<6:0>) and the interrupt level (ilr<3:0>) bit fields in the inttreg register. the new interrupt priority level is the priority of the pending interrupt. the interrupt sources are assigned to the ifsx, iecx and ipcx registers in the same sequence. for example, the int0 (external interrupt 0) is depicted as having a vector number and a natural order priority of 0. the int0if status bit is found in ifs0<0>, the int0ie enable bit in iec0<0> and the int0ip<2:0> priority bits are in the first position of ipc0 (ipc0<2:0>). although they are not specifically part of the interrupt control hardware, two of the cpu control registers con- tain bits that control interrupt functionality. the alu status register (sr) contains the ipl<2:0> bits (sr<7:5>). these indicate the current cpu interrupt priority level. the user may change the current cpu interrupt priority level by writing to the iplx bits. the corcon register contains the ipl3 bit, which together with ipl<2:0>, also indicates the current cpu interrupt priority level. ipl3 is a read-only bit so that the trap events cannot be masked by the users software. all interrupt registers are described in register 8-1 through register 8-35 , in the following sections. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 89 pic24fv16km204 family register 8-1: sr: alu status register u-0 u-0 u-0 u-0 u-0 u-0 u-0 r-0, hsc dc ( 1 ) bit 15 bit 8 r/w-0, hsc r/w-0, hsc r/w-0, hsc r-0, hsc r/w-0, hsc r/w-0, hsc r/w-0, hsc r/w-0, hsc ipl2 ( 2 , 3 ) ipl1 ( 2 , 3 ) ipl0 ( 2 , 3 ) ra ( 1 ) n ( 1 ) ov ( 1 ) z ( 1 ) c ( 1 ) bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-9 unimplemented: read as 0 bit 7-5 ipl<2:0>: cpu interrupt priority level status bits ( 2 , 3 ) 111 = cpu interrupt priority level is 7 (15); user interrupts are disabled 110 = cpu interrupt priority level is 6 (14) 101 = cpu interrupt priority level is 5 (13) 100 = cpu interrupt priority level is 4 (12) 011 = cpu interrupt priority level is 3 (11) 010 = cpu interrupt priority level is 2 (10) 001 = cpu interrupt priority level is 1 (9) 000 = cpu interrupt priority level is 0 (8) note 1: see register 3-1 for the description of these bits, which are not dedicated to interrupt control functions. 2: the ipl<2:0> bits are concatenated with the ipl3 bit (corcon<3>) to form the cpu interrupt priority level. the value in parentheses indicates the interrupt priority level if ipl3 = 1 . 3: the iplx status bits are read-only when nstdis (intcon1<15>) = 1 . note: bit 8 and bits 4 through 0 are described in section 3.0 cpu . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 90 ? 2013 microchip technology inc. register 8-2: corcon: cpu control register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 r/c-0, hsc r/w-0 u-0 u-0 i p l 3 ( 2 ) psv ( 1 ) bit 7 bit 0 legend: c = clearable bit hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-4 unimplemented: read as 0 bit 3 ipl3: cpu interrupt priority level status bit ( 2 ) 1 = cpu interrupt priority level is greater than 7 0 = cpu interrupt priority level is 7 or less bit 1-0 unimplemented: read as 0 note 1: see register 3-2 for the description of this bit, which is not dedicated to interrupt control functions. 2: the ipl3 bit is concatenated with the ipl<2:0> bits (sr<7:5>) to form the cpu interrupt priority level. note: bit 2 is described in section 3.0 cpu . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 91 pic24fv16km204 family register 8-3: intcon1: in terrupt control register 1 r/w-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 nstdis bit 15 bit 8 u-0 u-0 u-0 r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs u-0 matherr addrerr stkerr oscfail bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 nstdis: interrupt nesting disable bit 1 = interrupt nesting is disabled 0 = interrupt nesting is enabled bit 14-5 unimplemented: read as 0 bit 4 matherr: arithmetic error trap status bit 1 = overflow trap has occurred 0 = overflow trap has not occurred bit 3 addrerr: address error trap status bit 1 = address error trap has occurred 0 = address error trap has not occurred bit 2 stkerr: stack error trap status bit 1 = stack error trap has occurred 0 = stack error trap has not occurred bit 1 oscfail: oscillator failure trap status bit 1 = oscillator failure trap has occurred 0 = oscillator failure trap has not occurred bit 0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 92 ? 2013 microchip technology inc. register 8-4: intcon2: in terrupt control register 2 r/w-0 r-0, hsc u-0 u-0 u-0 u-0 u-0 u-0 altivt disi bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 int2ep int1ep int0ep bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 altivt: enable alternate interrupt vector table bit 1 = uses alternate interrupt vector table (aivt) 0 = uses standard (default) interrupt vector table (ivt) bit 14 disi: disi instruction status bit 1 = disi instruction is active 0 = disi instruction is not active bit 13-3 unimplemented: read as 0 bit 2 int2ep: external interrupt 2 edge detect polarity select bit 1 = interrupt is on the negative edge 0 = interrupt is on the positive edge bit 1 int1ep: external interrupt 1 edge detect polarity select bit 1 = interrupt is on the negative edge 0 = interrupt is on the positive edge bit 0 int0ep: external interrupt 0 edge detect polarity select bit 1 = interrupt is on the negative edge 0 = interrupt is on the positive edge downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 93 pic24fv16km204 family register 8-5: ifs0: interrupt flag status register 0 r/w-0, hs u-0 r/w-0, hs r/w-0, hs r/w-0, hs u-0 u-0 r/w-0, hs nvmif ad1if u1txif u1rxif cct2if bit 15 bit 8 r/w-0, hs r/w-0, hs r/w-0, hs u-0 r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs cct1if ccp4if ccp3if t1if ccp2if ccp1if int0if bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 nvmif: nvm interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 14 unimplemented: read as 0 bit 13 ad1if: a/d conversion complete interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 12 u1txif: uart1 transmitter interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 11 u1rxif: uart1 receiver interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 10-9 unimplemented: read as 0 bit 8 cct2if: capture/compare 2 timer interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 7 cct1if: capture/compare 1 timer interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 6 ccp4if: capture/compare 4 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 5 ccp3if: capture/compare 3 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 4 unimplemented: read as 0 bit 3 t1if: timer1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 2 ccp2if: capture/compare 2 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 ccp1if: capture/compare 1 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 int0if: external interrupt 0 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred downloaded from: http:///
pic24fv16km204 family ds30003030b-page 94 ? 2013 microchip technology inc. register 8-6: ifs1: interrupt flag status register 1 r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs u-0 u-0 u-0 u2txif u2rxif int2if cct4if cct3if bit 15 bit 8 u-0 r/w-0, hs u-0 r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs r/w-0, hs ccp5if int1if cnif cmif bcl1if ssp1if bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 u2txif: uart2 transmitter interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 14 u2rxif: uart2 receiver interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 13 int2if: external interrupt 2 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 12 cct4if: capture/compare 4 timer interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 11 cct3if: capture/compare 3 timer interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 10-7 unimplemented: read as 0 bit 6 ccp5if: capture/compare 5 event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 5 unimplemented: read as 0 bit 4 int1if: external interrupt 1 flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 3 cnif: input change notification interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 2 cmif: comparator interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 bcl1if: mssp1 i 2 c? bus collision interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 si2c1if: mssp1 spi/i 2 c event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 95 pic24fv16km204 family register 8-7: ifs2: interrupt flag status register 2 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0, hs u-0 c c t 5 i f bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-10 unimplemented: read as 0 bit 9 cct5if: capture/compare 5 timer interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 8-0 unimplemented: read as 0 register 8-8: ifs3: interrupt flag status register 3 u-0 r/w-0, hs u-0 u-0 u-0 u-0 u-0 u-0 r t c i f bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0, hs r/w-0, hs u-0 bcl2if ssp2if bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14 rtcif: real-time clock and calendar interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 13-3 unimplemented: read as 0 bit 2 bcl2if: mssp2 i 2 c? bus collision interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 ssp2if: mssp2 spi/i 2 c event interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 96 ? 2013 microchip technology inc. register 8-9: ifs4: interrupt flag status register 4 r/w-0, hs r/w-0, hs r/w-0, hs u-0 u-0 u-0 u-0 r/w-0, hs dac2if dac1if ctmuif h l v d i f bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0, hs r/w-0, hs u-0 u2erif u1erif bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 dac2if: digital-to-analog converter 2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 14 dac1if: digital-to-analog converter 1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 13 ctmuif: ctmu interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 12-9 unimplemented: read as 0 bit 8 hlvdif: high/low-voltage detect interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 7-3 unimplemented: read as 0 bit 2 u2erif: uart2 error interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 1 u1erif: uart1 error interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 97 pic24fv16km204 family register 8-10: ifs5: interrupt flag status register 5 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0, hs u l p w u i f bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-1 unimplemented: read as 0 bit 0 ulpwuif: ultra low-power wake-up interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred register 8-11: ifs6: interr upt flag status register 6 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0, hs r/w-0, hs clc2if clc1if bit 7 bit 0 legend: hs = hardware settable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-2 unimplemented: read as 0 bit 1 clc2if: configurable logic cell 2 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred bit 0 clc1if: configurable logic cell 1 interrupt flag status bit 1 = interrupt request has occurred 0 = interrupt request has not occurred downloaded from: http:///
pic24fv16km204 family ds30003030b-page 98 ? 2013 microchip technology inc. register 8-12: iec0: interrupt enable control register 0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 u-0 u-0 r/w-0 nvmie ad1ie u1txie u1rxie cct2ie bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 cct1ie ccp4ie ccp3ie t1ie ccp2ie ccp1ie int0ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 nvmie: nvm interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 14 unimplemented: read as 0 bit 13 ad1ie: a/d conversion complete interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 12 u1txie: uart1 transmitter interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 11 u1rxie: uart1 receiver interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 10-9 unimplemented: read as 0 bit 8 cct2ie: capture/compare 2 timer interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 7 cct1ie: capture/compare 1 timer interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 6 ccp4ie: capture/compare 4 event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 5 ccp3ie: capture/compare 3 event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 4 unimplemented: read as 0 bit 3 t1ie: timer1 interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 2 ccp2ie: capture/compare 2 event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 1 ccp1ie: capture/compare 1 event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 0 int0ie: external interrupt 0 enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 99 pic24fv16km204 family register 8-13: iec1: interrupt enable control register 1 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u2txie u2rxie int2ie cct4ie cct3ie bit 15 bit 8 u-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ccp5ie int1ie cnie cmie bcl1ie ssp1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 u2txie: uart2 transmitter interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 14 u2rxie: uart2 receiver interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 13 int2ie: external interrupt 2 enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 12 cct4ie: capture/compare 4 timer interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 11 cct3ie: capture/compare 3 timer interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 10-7 unimplemented: read as 0 bit 6 ccp5ie: capture/compare 5 event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 5 unimplemented: read as 0 bit 4 int1ie: external interrupt 1 enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 3 cnie: input change notification interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 2 cmie: comparator interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 1 bcl1ie: mssp1 i 2 c? bus collision interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 0 ssp1ie: mssp1 spi/i 2 c event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 100 ? 2013 microchip technology inc. register 8-14: iec2: interrupt enable control register 2 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 u-0 cct5ie bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-10 unimplemented: read as 0 bit 9 cct5ie: capture/compare 5 timer interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 8-0 unimplemented: read as 0 register 8-15: iec3: interrupt enable control register 3 u-0 r/w-0 u-0 u-0 u-0 u-0 u-0 u-0 r t c i e bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 u-0 bcl2ie ssp2ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14 rtcie: real-time clock and calendar interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 13-3 unimplemented: read as 0 bit 2 bcl2ie: mssp2 i 2 c? bus collision interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 1 ssp2ie: mssp2 spi/i 2 c event interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 101 pic24fv16km204 family register 8-16: iec4: interrupt enable control register 4 r/w-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 r/w-0 dac2ie dac1ie ctmuie h l v d i e bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 u-0 u2erie u1erie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 dac2ie: digital-to-analog converter 2 interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 14 dac1ie: digital-to-analog converter 1 interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 13 ctmuie: ctmu interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 12-9 unimplemented: read as 0 bit 8 hlvdie: high/low-voltage detect interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 7-3 unimplemented: read as 0 bit 2 u2erie: uart2 error interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 1 u1erie: uart1 error interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 102 ? 2013 microchip technology inc. register 8-17: iec5: interrupt enable control register 5 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 u l p w u i e bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-1 unimplemented: read as 0 bit 0 ulpwuie: ultra low-power wake-up interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled register 8-18: iec6: interrupt enable control register 5 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-0 clc2ie clc1ie bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-2 unimplemented: read as 0 bit 1 clc2ie: configurable logic cell 2 interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled bit 0 clc1ie: configurable logic cell 1 interrupt enable bit 1 = interrupt request is enabled 0 = interrupt request is not enabled downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 103 pic24fv16km204 family register 8-19: ipc0: interrupt pr iority control register 0 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 t1ip2 t1ip1 t1ip0 ccp2ip2 ccp2ip1 ccp2ip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ccp1ip2 ccp1ip1 ccp1ip0 int0ip2 int0ip1 int0ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 t1ip<2:0>: timer1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as 0 bit 10-8 ccp2ip<2:0>: capture/compare 2 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 ccp1ip<2:0>: capture/compare 1 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as 0 bit 2-0 int0ip<2:0>: external interrupt 0 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 104 ? 2013 microchip technology inc. register 8-20: ipc1: interrupt pr iority control register 1 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 cct1ip2 cct1ip1 cct1ip0 ccp4ip2 ccp4ip1 ccp4ip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ccp3ip2 ccp3ip1 ccp3ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 cct1ip<2:0>: capture/compare 1 timer interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as 0 bit 10-8 ccp4ip<2:0>: capture/compare 4 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 ccp3ip<2:0>: capture/compare 3 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 105 pic24fv16km204 family register 8-21: ipc2: interrupt pr iority control register 2 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 u1rxip2 u1rxip1 u1rxip0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 cct2ip2 cct2ip1 cct2ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 u1rxip<2:0>: uart1 receiver interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11-3 unimplemented: read as 0 bit 2-0 cct2ip<2:0>: capture/compare 2 timer interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 106 ? 2013 microchip technology inc. register 8-22: ipc3: interrupt pr iority control register 3 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 nvmip2 nvmip1 nvmip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 ad1ip2 ad1ip1 ad1ip0 u1txip2 u1txip1 u1txip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 nvmip<2:0>: nvm interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11-7 unimplemented: read as 0 bit 6-4 ad1ip<2:0>: a/d conversion complete interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as 0 bit 2-0 u1txip<2:0>: uart1 transmitter interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 107 pic24fv16km204 family register 8-23: ipc4: interrupt pr iority control register 4 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 cnip2 cnip1 cnip0 cmip2 cmip1 cmip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 bcl1ip2 bcl1ip1 bcl1ip0 ssp1ip2 ssp1ip1 ssp1ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 cnip<2:0>: input change notification interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as 0 bit 10-8 cmip<2:0>: comparator interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 bcl1ip<2:0>: mssp1 i 2 c? bus collision interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as 0 bit 2-0 ssp1ip<2:0>: mssp1 spi/i 2 c event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 108 ? 2013 microchip technology inc. register 8-24: ipc5: interrupt pr iority control register 5 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ccp5ip2 ccp5ip1 ccp5ip0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 int1ip2 int1ip1 int1ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 ccp5ip<2:0>: capture/compare 5 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7-3 unimplemented: read as 0 bit 2-0 int1ip<2:0>: external interrupt 1 priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 109 pic24fv16km204 family register 8-25: ipc6: interrupt pr iority control register 6 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 cct3ip2 cct3ip1 cct3ip0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 cct3ip<2:0>: capture/compare 3 timer interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11-0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 110 ? 2013 microchip technology inc. register 8-26: ipc7: interrupt pr iority control register 7 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 u2txip2 u2txip1 u2txip0 u2rxip2 u2rxip1 u2rxip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 int2ip2 int2ip1 int2ip0 cct4ip2 cct4ip1 cct4ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 u2txip<2:0>: uart2 transmitter interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as 0 bit 10-8 u2rxip<2:0>: uart2 receiver interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 int2ip<2:0>: external interrupt 2 priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as 0 bit 2-0 cct4ip<2:0>: capture/compare 4 timer interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 111 pic24fv16km204 family register 8-27: ipc10: interrupt priority control register 10 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 cct5ip2 cct5ip1 cct5ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-7 unimplemented: read as 0 bit 6-4 cct5ip<2:0>: capture/compare 5 timer interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 112 ? 2013 microchip technology inc. register 8-28: ipc12: interrupt priority control register 12 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 bcl2ip2 bcl2ip1 bcl2ip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ssp2ip2 ssp2ip1 ssp2ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 bcl2ip<2:0>: mssp2 i 2 c? bus collision interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 ssp2ip<2:0>: mssp2 spi/i 2 c event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 113 pic24fv16km204 family register 8-29: ipc15: interrupt priority control register 15 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 rtcip2 rtcip1 rtcip0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 rtcip<2:0>: real-time clock and calendar interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7-0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 114 ? 2013 microchip technology inc. register 8-30: ipc16: interrupt priority control register 16 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 u2erip2 u2erip1 u2erip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 u1erip2 u1erip1 u1erip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 u2erip<2:0>: uart2 error interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 u1erip<2:0>: uart1 error interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 115 pic24fv16km204 family register 8-31: ipc18: interrupt priority control register 18 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 hlvdip2 hlvdip1 hlvdip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-3 unimplemented: read as 0 bit 2-0 hlvdip<2:0>: high/low-voltage detect interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 116 ? 2013 microchip technology inc. register 8-32: ipc19: interrupt priority control register 19 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 dac2ip2 dac2ip1 dac2ip0 dac1ip2 dac1ip1 dac1ip0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ctmuip2 ctmuip1 ctmuip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 dac2ip<2:0>: digital-to-analog converter 2 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 11 unimplemented: read as 0 bit 10-8 dac1ip<2:0>: digital-to-analog converter 1 event interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 7 unimplemented: read as 0 bit 6-4 ctmuip<2:0>: ctmu interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3-0 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 117 pic24fv16km204 family register 8-33: ipc20: interrupt priority control register 20 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-0 r/w-0 ulpwuip2 ulpwuip1 ulpwuip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-3 unimplemented: read as 0 bit 2-0 ulpwuip<2:0>: ultra low-power wake-up interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled register 8-34: ipc24: interrupt priority control register 24 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 r/w-1 r/w-0 r/w-0 u-0 r/w-1 r/w-0 r/w-0 clc2ip2 clc2ip1 clc2ip0 clc1ip2 clc1ip1 clc1ip0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-7 unimplemented: read as 0 bit 6-4 clc2ip<2:0>: clc2 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled bit 3 unimplemented: read as 0 bit 2-0 clc1ip<2:0>: clc1 interrupt priority bits 111 = interrupt is priority 7 (highest priority interrupt) 001 = interrupt is priority 1 000 = interrupt source is disabled downloaded from: http:///
pic24fv16km204 family ds30003030b-page 118 ? 2013 microchip technology inc. register 8-35: inttreg: interrupt control and status register r-0 u-0 r/w-0 u-0 r-0 r-0 r-0 r-0 cpuirq v h o l d ilr3 ilr2 ilr1 ilr0 bit 15 bit 8 u-0 r-0 r-0 r-0 r-0 r-0 r-0 r-0 vecnum6 vecnum5 vecnum4 vecnum3 vecnum2 vecnum1 vecnum0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 cpuirq: interrupt request from interrupt controller cpu bit 1 = an interrupt request has occurred but has not yet been acknowledged by the cpu (this will happen when the cpu priority is higher than the interrupt priority) 0 = no interrupt request is left unacknowledged bit 14 unimplemented: read as 0 bit 13 vhold: vector hold bit allows vector number capture and changes which interrupt is stored in th e vecnum<6:0> bits: 1 = vecnum<6:0> will contain the value of the highest priority pending interrupt, instead of the current interrupt 0 = vecnum<6:0> will contain the value of the last acknowledged interrupt (last interrupt that has occurred with higher priority than the cpu, even if other interrupts are pending) bit 12 unimplemented: read as 0 bit 11-8 ilr<3:0>: new cpu interrupt priority level bits 1111 = cpu interrupt priority level is 15 0001 = cpu interrupt priority level is 1 0000 = cpu interrupt priority level is 0 bit 7 unimplemented: read as 0 bit 6-0 vecnum<6:0>: vector number of pending interrupt bits 0111111 = interrupt vector pending is number 135 0000001 = interrupt vector pending is number 9 0000000 = interrupt vector pending is number 8 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 119 pic24fv16km204 family 8.4 interrupt setup procedures 8.4.1 initialization to configure an interrupt source: 1. set the nstdis control bit (intcon1<15>) if nested interrupts are not desired. 2. select the user-assigned priority level for the interrupt source by writing the control bits in the appropriate ipcx register. the priority level will depend on the specific application and type of interrupt source. if multiple priority levels are not desired, the ipcx register control bits for all enabled interrupt sources may be programmed to the same non-zero value. 3. clear the interrupt flag status bit associated with the peripheral in the associated ifsx register. 4. enable the interrupt source by setting the interrupt enable control bit associated with the source in the appropriate iecx register. 8.4.2 interrupt service routine the method that is used to declare an isr (interrupt service routine) and initialize the ivt with the correct vector address depends on the programming language (i.e., c or assembly), and the language development toolsuite that is used to develop the application. in general, the user must clear the interrupt flag in the appropriate ifsx register for the source of the interrupt that the isr handles. otherwise, the isr will be re-entered immediately after exiting the routine. if the isr is coded in assembly language, it must be termi- nated using a retfie instruction to unstack the saved pc value, srl value and old cpu priority level. 8.4.3 trap service routine (tsr) a trap service routine (tsr) is coded like an isr, except that the appropriate trap status flag in the intcon1 register must be cleared to avoid re-entry into the tsr. 8.4.4 interrupt disable all user interrupts can be disabled using the following procedure: 1. push the current sr value onto the software stack using the push instruction. 2. force the cpu to priority level 7 by inclusive oring the value, 0eh, with srl. to enable user interrupts, the pop instruction may be used to restore the previous sr value. only user interrupts with a priority level of 7 or less can be disabled. trap sources (levels 8-15) cannot be disabled. the disi instruction provides a convenient way to disable interrupts of priority levels 1-6 for a fixed period. level 7 interrupt sources are not disabled by the disi instruction. note: at a device reset, the ipcx registers are initialized, such that all user interrupt sources are assigned to priority level 4. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 120 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 121 pic24fv16km204 family 9.0 oscillator configuration the oscillator system for the pic24fv16km204 family of devices has the following features: a total of five external and internal oscillator options as clock sources, providing 11 different clock modes. on-chip 4x phase locked loop (pll) to boost internal operating frequency on select internal and external oscillator sources. software-controllable switching between various clock sources. software-controllable postscaler for selective clocking of cpu for system power savings. system frequency range declaration bits for exter- nal clock (ec) mode. when using an ec source, the current consumption is reduced by setting the declaration bits to the expected frequency range. a fail-safe clock monitor (fscm) that detects clock failure and permits safe application recovery or shutdown. a simplified diagram of the oscillator system is shown in figure 9-1 . figure 9-1: pic24fxxxxx family clock diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive refer- ence source. for more information on oscillator configuration, refer to the pic24f family reference manual , oscillator with 500 khz low-power frc (ds39726). secondary oscillator soscen enable oscillator sosco sosci clock source option for other modules osci osco primary oscillator xt, hs, ec clkdiv<10:8> wdt, pwrt, dswdt frcdiv 31 khz (nominal) 8 mhz frc sosc lprc clock control logic fail-safe clock monitor frc 4 x pll 8 mhz 4 mhz cpu peripherals clkdiv<14:12> clko reference clock generator refo refocon<15:8> oscillator 500 khz lpfrc oscillator lprc oscillator xtpll, hspll ecpll, frcpll postscaler postscaler downloaded from: http:///
pic24fv16km204 family ds30003030b-page 122 ? 2013 microchip technology inc. 9.1 cpu clocking scheme the system clock source can be provided by one of four sources: primary oscillator (posc) on the osci and osco pins secondary oscillator (sosc) on the sosci and sosco pins the pic24fxxxxx family devices consist of two types of secondary oscillator: - high-power secondary oscillator - low-power secondary oscillator these can be selected by using the soscsel (fosc<5>) bit. fast internal rc (frc) oscillator: - 8 mhz frc oscillator - 500 khz lower power frc oscillator low-power internal rc (lprc) oscillator with two modes: - high-power/high-accuracy mode - low-power/low-accuracy mode the primary oscillator and 8 mhz frc sources have the option of using the internal 4x pll. the frequency of the frc clock source can optionally be reduced by the programmable clock divider. the selected clock source generates the processor and peripheral clock sources. the processor clock source is divided by two to produce the internal instruction cycle clock, f cy . in this document, the instruction cycle clock is also denoted by f osc /2. the internal instruction cycle clock, f osc /2, can be provided on the osco i/o pin for some operating modes of the primary oscillator. 9.2 initial configuration on por the oscillator source (and operating mode) that is used at a device power-on reset (por) event is selected using configuration bit settings. the oscillator configuration bit settings are located in the configuration registers in the program memory (for more information, see section 25.1 configuration bits ). the primary oscillator configuration bits, poscmd<1:0> (fosc<1:0>), and the initial oscillator select configuration bits, fnosc<2:0> (foscsel<2:0>), select the oscillator source that is used at a por. the frc primary oscillator with postscaler (frcdiv) is the default (unprogrammed) selection. the secondary oscillator, or one of the internal oscillators, may be chosen by programming these bit locations. the ec mode frequency range configuration bits, poscfreq<1:0> (fosc<4:3>), optimize power consumption when running in ec mode. the default configuration is frequency range is greater than 8 mhz. the configuration bits allow users to choose between the various clock modes, shown in tab l e 9 - 1 . 9.2.1 clock switching mode configuration bits the fcksm<1:0> configuration bits (fosc<7:6>) are used jointly to configure device clock switching and the fscm. clock switching is enabled only when fcksm1 is programmed ( 0 ). the fscm is enabled only when fcksm<1:0> are both programmed ( 00 ). table 9-1: configuration bit va lues for clock selection oscillator mode oscillator source poscmd<1:0> fnosc<2:0> notes 8 mhz frc oscillator with postscaler (frcdiv) internal 11 111 1 , 2 500 khz frc oscillator with postscaler (lpfrcdiv) internal 11 110 1 low-power rc oscillator (lprc) internal 11 101 1 secondary (timer1) oscillator (sosc) secondary 00 100 1 primary oscillator (hs) with pll module (hspll) primary 10 011 primary oscillator (ec) with pll module (ecpll) primary 00 011 primary oscillator (hs) primary 10 010 primary oscillator (xt) primary 01 010 primary oscillator (ec) primary 00 010 8 mhz frc oscillator with pll module (frcpll) internal 11 001 1 8 mhz frc oscillator (frc) internal 11 000 1 note 1: the osco pin function is determined by the osciofnc configuration bit. 2: this is the default oscillator mode for an unprogrammed (erased) device. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 123 pic24fv16km204 family 9.3 control registers the operation of the oscillator is controlled by three special function registers (sfrs): osccon clkdiv osctun the osccon register ( register 9-1 ) is the main control register for the oscillator. it controls clock source switching and allows the monitoring of clock sources. the clock divider register ( register 9-2 ) controls the features associated with doze mode, as well as the postscaler for the frc oscillator. the frc oscillator tune register ( register 9-3 ) allows the user to fine-tune the frc oscillator over a range of approximately 5.25%. each bit increment or decre- ment changes the factory calibrated frequency of the frc oscillator by a fixed amount. register 9-1: osccon: os cillator control register u-0 r-0, hsc r-0, hsc r-0, hsc u-0 r/w-x ( 1 ) r/w-x ( 1 ) r/w-x ( 1 ) cosc2 cosc1 cosc0 nosc2 nosc1 nosc0 bit 15 bit 8 r/so-0, hsc u-0 r-0, hsc ( 2 ) u-0 r/co-0, hs r/w-0 ( 3 ) r/w-0 r/w-0 clklock l o c k cf soscdrv soscen oswen bit 7 bit 0 legend: hsc = hardware settable/clearable bit hs = hardware settable bit co = clearable only bit so = settable only bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 cosc<2:0>: current oscillator selection bits 111 = 8 mhz fast rc oscillator with postscaler (frcdiv) 110 = 500 khz low-power fast rc oscillator (frc) with postscaler (lpfrcdiv) 101 = low-power rc oscillator (lprc) 100 = secondary oscillator (sosc) 011 = primary oscillator with pll module (xtpll, hspll, ecpll) 010 = primary oscillator (xt, hs, ec) 001 = 8 mhz frc oscillator with postscaler and pll module (frcpll) 000 = 8 mhz frc oscillator (frc) bit 11 unimplemented: read as 0 bit 10-8 nosc<2:0>: new oscillator selection bits ( 1 ) 111 = 8 mhz fast rc oscillator with postscaler (frcdiv) 110 = 500 khz low-power fast rc oscillator (frc) with postscaler (lpfrcdiv) 101 = low-power rc oscillator (lprc) 100 = secondary oscillator (sosc) 011 = primary oscillator with pll module (xtpll, hspll, ecpll) 010 = primary oscillator (xt, hs, ec) 001 = 8 mhz frc oscillator with postscaler and pll module (frcpll) 000 = 8 mhz frc oscillator (frc) note 1: reset values for these bits are determined by the fnoscx configuration bits. 2: this bit also resets to 0 during any valid clock switch or whenever a non-pll clock mode is selected. 3: when sosc is selected to run from a digital clock input, rather than an external crystal (soscsrc = 0 ), this bit has no effect. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 124 ? 2013 microchip technology inc. bit 7 clklock: clock selection lock enable bit if fscm is enabled (fcksm1 = 1 ): 1 = clock and pll selections are locked 0 = clock and pll selections are not locked and may be modified by setting the oswen bit if fscm is disabled (fcksm1 = 0 ): clock and pll selections are never locked and may be modified by setting the oswen bit. bit 6 unimplemented: read as 0 bit 5 lock: pll lock status bit ( 2 ) 1 = pll module is in lock or pll module start-up timer is satisfied 0 = pll module is out of lock, pll start-up timer is running or pll is disabled bit 4 unimplemented: read as 0 bit 3 cf: clock fail detect bit 1 = fscm has detected a clock failure 0 = no clock failure has been detected bit 2 soscdrv : secondary oscillator drive strength bit ( 3 ) 1 = high-power sosc circuit is selected 0 = low/high-power select is done via the soscsrc configuration bit bit 1 soscen: 32 khz secondary oscillator (sosc) enable bit 1 = enables the secondary oscillator 0 = disables the secondary oscillator bit 0 oswen: oscillator switch enable bit 1 = initiates an oscillator switch to the clock source specified by the nosc<2:0> bits 0 = oscillator switch is complete register 9-1: osccon: oscillator control register (continued) note 1: reset values for these bits are determined by the fnoscx configuration bits. 2: this bit also resets to 0 during any valid clock switch or whenever a non-pll clock mode is selected. 3: when sosc is selected to run from a digital clock input, rather than an external crystal (soscsrc = 0 ), this bit has no effect. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 125 pic24fv16km204 family register 9-2: clkdiv: clock divider register r/w-0 r/w-0 r/w-1 r/w-1 r/w-0 r/w-0 r/w-0 r/w-1 roi doze2 doze1 doze0 dozen ( 1 ) rcdiv2 rcdiv1 rcdiv0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 roi: recover on interrupt bit 1 = interrupts clear the dozen bit, and reset the cpu and peripheral clock ratio to 1:1 0 = interrupts have no effect on the dozen bit bit 14-12 doze<2:0>: cpu and peripheral clock ratio select bits 111 = 1:128 110 = 1:64 101 = 1:32 100 = 1:16 011 = 1:8 010 = 1:4 001 = 1:2 000 = 1:1 bit 11 dozen: doze enable bit ( 1 ) 1 = doze<2:0> bits specify the cpu and peripheral clock ratio 0 = cpu and peripheral clock ratio are set to 1:1 bit 10-8 rcdiv<2:0>: frc postscaler select bits when cosc<2:0> (osccon<14:12>) = 111 : 111 = 31.25 khz (divide-by-256) 110 = 125 khz (divide-by-64) 101 = 250 khz (divide-by-32) 100 = 500 khz (divide-by-16) 011 = 1 mhz (divide-by-8) 010 = 2 mhz (divide-by-4) 001 = 4 mhz (divide-by-2) C default 000 = 8 mhz (divide-by-1) when cosc<2:0> (osccon<14:12>) = 110 : 111 = 1.95 khz (divide-by-256) 110 = 7.81 khz (divide-by-64) 101 = 15.62 khz (divide-by-32) 100 = 31.25 khz (divide-by-16) 011 = 62.5 khz (divide-by-8) 010 = 125 khz (divide-by-4) 001 = 250 khz (divide-by-2) C default 000 = 500 khz (divide-by-1) bit 7-0 unimplemented: read as 0 note 1: this bit is automatically cleared when the roi bit is set and an interrupt occurs. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 126 ? 2013 microchip technology inc. register 9-3: osctun: frc oscillator tune register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tun5 ( 1 ) tun4 ( 1 ) tun3 ( 1 ) tun2 ( 1 ) tun1 ( 1 ) tun0 ( 1 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-6 unimplemented: read as 0 bit 5-0 tun<5:0>: frc oscillator tuning bits ( 1 ) 011111 = maximum frequency deviation 011110 000001 000000 = center frequency, oscillator is running at factory calibrated frequency 111111 100001 100000 = minimum frequency deviation note 1: increments or decrements of tun<5:0> may not change the frc frequency in equal steps over the frc tuning range and may not be monotonic. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 127 pic24fv16km204 family 9.4 clock switching operation with few limitations, applications are free to switch between any of the four clock sources (posc, sosc, frc and lprc) under software control and at any time. to limit the possible side effects that could result from this flexibility, pic24f devices have a safeguard lock built into the switching process. 9.4.1 enabling clock switching to enable clock switching, the fcksm1 configuration bit in the fosc configuration register must be programmed to 0 . (refer to section 25.0 special features for further details.) if the fcksm1 configuration bit is unprogrammed ( 1 ), the clock switching function and fscm function are disabled; this is the default setting. the noscx control bits (osccon<10:8>) do not control the clock selection when clock switching is disabled. however, the coscx bits (osccon<14:12>) will reflect the clock source selected by the fnoscx configuration bits. the oswen control bit (osccon<0>) has no effect when clock switching is disabled; it is held at 0 at all times. 9.4.2 oscillator switching sequence at a minimum, performing a clock switch requires this basic sequence: 1. if desired, read the coscx bits (osccon<14:12>) to determine the current oscillator source. 2. perform the unlock sequence to allow a write to the osccon register high byte. 3. write the appropriate value to the noscx bits (osccon<10:8>) for the new oscillator source. 4. perform the unlock sequence to allow a write to the osccon register low byte. 5. set the oswen bit to initiate the oscillator switch. once the basic sequence is completed, the system clock hardware responds automatically, as follows: 1. the clock switching hardware compares the coscx bits with the new value of the noscx bits. if they are the same, then the clock switch is a redundant operation. in this case, the oswen bit is cleared automatically and the clock switch is aborted. 2. if a valid clock switch has been initiated, the lock (osccon<5>) and cf (osccon<3>) bits are cleared. 3. the new oscillator is turned on by the hardware if it is not currently running. if a crystal oscillator must be turned on, the hardware will wait until the ost expires. if the new source is using the pll, then the hardware waits until a pll lock is detected (lock = 1 ). 4. the hardware waits for 10 clock cycles from the new clock source and then performs the clock switch. 5. the hardware clears the oswen bit to indicate a successful clock transition. in addition, the noscx bits value is transferred to the coscx bits. 6. the old clock source is turned off at this time, with the exception of lprc (if wdt, fscm or rtcc with lprc as a clock source is enabled) or sosc (if soscen remains enabled). note: the primary oscillator mode has three different submodes (xt, hs and ec), which are determined by the poscmdx configuration bits. while an application can switch to and from primary oscillator mode in software, it cannot switch between the different primary submodes without reprogramming the device. note 1: the processor will continue to execute code throughout the clock switching sequence. timing-sensitive code should not be executed during this time. 2: direct clock switches between any primary oscillator mode with pll and frcpll mode are not permitted. this applies to clock switches in either direc- tion. in these instances, the application must switch to frc mode as a transitional clock source between the two pll modes. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 128 ? 2013 microchip technology inc. the following code sequence for a clock switch is recommended: 1. disable interrupts during the osccon register unlock and write sequence. 2. execute the unlock sequence for the osccon high byte by writing 78h and 9ah to osccon<15:8>, in two back-to-back instructions. 3. write the new oscillator source to the noscx bits in the instruction immediately following the unlock sequence. 4. execute the unlock sequence for the osccon low byte by writing 46h and 57h to osccon<7:0>, in two back-to-back instructions. 5. set the oswen bit in the instruction immediately following the unlock sequence. 6. continue to execute code that is not clock-sensitive (optional). 7. invoke an appropriate amount of software delay (cycle counting) to allow the selected oscillator and/or pll to start and stabilize. 8. check to see if oswen is 0 . if it is, the switch was successful. if oswen is still set, then check the lock bit to determine the cause of failure. the core sequence for unlocking the osccon register and initiating a clock switch is shown in example 9-1 and example 9-2 . example 9-1: assembly code sequence for clock switching example 9-2: basic c code sequence for clock switching 9.5 reference clock output in addition to the clko output (f osc /2) available in certain oscillator modes, the device clock in the pic24fxxxxx family devices can also be configured to provide a reference clock output signal to a port pin. this feature is available in all oscillator configurations and allows the user to select a greater range of clock submultiples to drive external devices in the application. this reference clock output is controlled by the refocon register ( register 9-4 ). setting the roen bit (refocon<15>) makes the clock signal available on the refo pin. the rodiv<3:0> bits (refocon<11:8>) enable the selection of 16 different clock divider options. the rosslp and rosel bits (refocon<13:12>) control the availability of the reference output during sleep mode. the rosel bit determines if the oscillator on osc1 and osc2, or the current system clock source, is used for the reference clock output. the rosslp bit determines if the reference source is available on refo when the device is in sleep mode. to use the reference clock output in sleep mode, both the rosslp and rosel bits must be set. the device clock must also be configured for one of the primary modes (ec, hs or xt); otherwise, if the rosel bit is not also set, the oscillator on osc1 and osc2 will be powered down when the device enters sleep mode. clearing the rosel bit allows the reference output frequency to change as the system clock changes during any clock switches. ;place the new oscillator selection in w0 ;oscconh (high byte) unlock sequence mov #oscconh, w1 mov #0x78, w2 mov #0x9a, w3 mov.b w2, [w1] mov.b w3, [w1] ;set new oscillator selection mov.b wreg, oscconh ;oscconl (low byte) unlock sequence mov #oscconl, w1 mov #0x46, w2 mov #0x57, w3 mov.b w2, [w1] mov.b w3, [w1] ;start oscillator switch operation bset osccon,#0 //use compiler built-in function to write new clock setting __builtin_write_oscconh(0x01); //0x01 switches to frcpll //use compiler built-in function to set the oswen bit. __builtin_write_oscconl(oscconl | 0x01); //optional: wait for clock switch sequence to complete while(oscconbits.oswen == 1); downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 129 pic24fv16km204 family register 9-4: refocon: reference oscillator control register r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 roen rosslp rosel rodiv3 rodiv2 rodiv1 rodiv0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 roen: reference oscillator output enable bit 1 = reference oscillator is enabled on the refo pin 0 = reference oscillator is disabled bit 14 unimplemented: read as 0 bit 13 rosslp: reference oscillator output stop in sleep bit 1 = reference oscillator continues to run in sleep 0 = reference oscillator is disabled in sleep bit 12 rosel: reference oscillator source select bit 1 = primary oscillator is used as the base clock ( 1 ) 0 = system clock is used as the base clock; base clock reflects any clock switching of the device bit 11-8 rodiv<3:0>: reference oscillator divisor select bits 1111 = base clock value divided by 32,768 1110 = base clock value divided by 16,384 1101 = base clock value divided by 8,192 1100 = base clock value divided by 4,096 1011 = base clock value divided by 2,048 1010 = base clock value divided by 1,024 1001 = base clock value divided by 512 1000 = base clock value divided by 256 0111 = base clock value divided by 128 0110 = base clock value divided by 64 0101 = base clock value divided by 32 0100 = base clock value divided by 16 0011 = base clock value divided by 8 0010 = base clock value divided by 4 0001 = base clock value divided by 2 0000 = base clock value bit 7-0 unimplemented: read as 0 note 1: the crystal oscillator must be enabled using the fosc<2:0> bits; the crystal maintains the operation in sleep mode. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 130 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 131 pic24fv16km204 family 10.0 power-saving features the pic24fv16km204 family of devices provides the ability to manage power consumption by selectively managing clocking to the cpu and the peripherals. in general, a lower clock frequency and a reduction in the number of circuits being clocked constitutes lower consumed power. all pic24f devices manage power consumption in four different ways: clock frequency instruction-based sleep and idle modes software controlled doze mode selective peripheral control in software combinations of these methods can be used to selectively tailor an applications power consumption, while still maintaining critical application features, such as timing-sensitive communications. 10.1 clock frequency and clock switching pic24f devices allow for a wide range of clock frequencies to be selected under application control. if the system clock configuratio n is not locked, users can choose low-power or high-precision oscillators by simply changing the noscx bits. the process of changing a system clock during operation, as well as limitations to the process, are discussed in more detail in section 9.0 oscillator configuration . 10.2 instruction-based power-saving modes pic24f devices have two special power-saving modes that are entered through the execution of a special pwrsav instruction. sleep mode stops clock operation and halts all code execution; idle mode halts the cpu and code execution, but allows peripheral modules to continue operation. the c syntax of the pwrsav instruction is shown in example 10-1 . sleep and idle modes can be exited as a result of an enabled interrupt, wdt time-out or a device reset. when the device exits these modes, it is said to wake-up. 10.2.1 sleep mode sleep mode includes these features: the system clock source is shut down. if an on-chip oscillator is used, it is turned off. the device current consumption will be reduced to a minimum provided that no i/o pin is sourcing current. the i/o pin directions and states are frozen. the fail-safe clock monitor does not operate during sleep mode since the system clock source is disabled. the lprc clock will continue to run in sleep mode if the wdt or rtcc with lprc as the clock source is enabled. the wdt, if enabled, is automatically cleared prior to entering sleep mode. some device features or peripherals may continue to operate in sleep mode. this includes items, such as the input change notification on the i/o ports or peripherals that use an external clock input. any peripheral that requires the sys- tem clock source for its operation will be disabled in sleep mode. the device will wake-up from sleep mode on any of these events: on any interrupt source that is individually enabled on any form of device reset on a wdt time-out on wake-up from sleep, the processor will restart with the same clock source that was active when sleep mode was entered. example 10-1: c power-saving entry note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information, refer to the pic24f family reference manual , power-saving features with v bat (ds30622). this frm describes some features which are not implemented in this device. sections related to the v bat pin and deep sleep do not apply to the pic24fv16km204 family. note: sleep_mode and idle_mode are constants defined in the assembler include file for the selected device. sleep(); //put the device into sleep mode idle(); //put the device into idle mode downloaded from: http:///
pic24fv16km204 family ds30003030b-page 132 ? 2013 microchip technology inc. 10.2.2 idle mode idle mode includes these features: the cpu will stop executing instructions. the wdt is automatically cleared. the system clock source remains active. by default, all peripheral modules continue to operate normally from the system clock source, but can also be selectively disabled (see section 10.6 selective peripheral module control ). if the wdt or fscm is enabled, the lprc will also remain active. the device will wake from idle mode on any of these events: any interrupt that is individually enabled any device reset a wdt time-out on wake-up from idle, the clock is reapplied to the cpu and instruction execution begins immediately, starting with the instruction following the pwrsav instruction or the first instruction in the isr. 10.2.3 interrupts coincident with power save instructions any interrupt that coincides with the execution of a pwrsav instruction will be held off until entry into sleep or idle mode has completed. the device will then wake-up from sleep or idle mode. 10.2.3.1 power-on resets ( pors ) v dd voltage is monitored to produce pors. when a true por occurs, the entire device is reset. 10.3 ultra low-power wake-up the ultra low-power wake-up (ulpwu) on pin, rb0, allows a slow falling voltage to generate an interrupt without excess current consumption. to use this feature: 1. charge the capacitor on rb0 by configuring the rb0 pin to an output and setting it to 1 . 2. stop charging the capacitor by configuring rb0 as an input. 3. discharge the capacitor by setting the ulpen and ulpsink bits in the ulpwcon register. 4. configure sleep mode. 5. enter sleep mode. when the voltage on rb0 drops below v il , the device wakes up and executes the next instruction. this feature provides a low-power technique for periodically waking up the device from sleep mode. the time-out is dependent on the discharge time of the rc circuit on rb0. when the ulpwu module wakes the device from sleep mode, the ulpwuif bit (ifs5<0>) is set. soft- ware can check this bit upon wake-up to determine the wake-up source. see example 10-2 for initializing the ulpwu module. example 10-2: ultra low-power wake-up initialization a series resistor, between rb0 and the external capacitor provides overcurrent protection for the an2/ulpwu/rb0 pin and enables software calibration of the time-out (see figure 10-1 ). figure 10-1: series resistor a timer can be used to measure the charge time and discharge time of the capacitor. the charge time can then be adjusted to provide the desired delay in sleep. this technique compensates for the affects of temper- ature, voltage and component accuracy. the peripheral can also be configured as a simple, programmable low-voltage detect (lvd) or temperature sensor. / /******************************* // 1. charge the capacitor on rb0 //******************************* trisbbits.trisb0 = 0; latbbits.latb0 = 1; for(i = 0; i < 10000; i++) nop(); //***************************** //2. stop charging the capacitor // on rb0 //***************************** trisbbits.trisb0 = 1; //***************************** //3. enable ulpwu interrupt //***************************** ifs5bits.ulpwuif = 0; iec5bits.ulpwuie = 1; ipc21bits.ulpwuip = 0x7; //***************************** //4. enable the ultra low power // wakeup module and allow // capacitor discharge //***************************** ulpwconbits.ulpen = 1; ulpwconbit.ulpsink = 1; //***************************** //5. enter sleep mode //***************************** sleep(); //for sleep, execution will //resume here r 1 c 1 rb0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 133 pic24fv16km204 family register 10-1: ulpwcon: ulpwu control register r/w-0 u-0 r/w-0 u-0 u-0 u-0 u-0 r/w-0 ulpen ulpsidl ulpsink bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 ulpen: ulpwu module enable bit 1 = module is enabled 0 = module is disabled bit 14 unimplemented: read as 0 bit 13 ulpsidl: ulpwu stop in idle select bit 1 = discontinues module operation when the device enters idle mode 0 = continues module operation in idle mode bit 12-9 unimplemented: read as 0 bit 8 ulpsink: ulpwu current sink enable bit 1 = current sink is enabled 0 = current sink is disabled bit 7-0 unimplemented: read as 0 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 134 ? 2013 microchip technology inc. 10.4 voltage regulator-based power-saving features the pic24fv16km204 family series devices have a voltage regulator that has the ability to alter functionality to provide power savings. the on-chip regulator is made up of two basic modules: the voltage regulator (vreg) and the retention regulator (retreg). with the combination of vreg and retreg, the following power modes are available: 10.4.1 run mode in run mode, the main vreg is providing a regulated voltage with enough current to supply a device running at full speed and the device is not in sleep mode. the retreg may or may not be running, but is unused. 10.4.2 sleep mode in sleep mode, the device is in sleep and the main vreg is providing a regulated voltage to the core. by default, in sleep mode, the regulator enters a low-power standby state which consumes reduced quiescent current. the pmslp bit (rcon<8>) controls the regulator state in sleep mode. if the pmslp bit is set, the program flash memory will stay powered on during sleep mode and the regulator will stay in its full-power mode. 10.4.3 retention regulator the retention regulator, sometimes referred to as the low-voltage regulator, is designed to provide power to the core at a lower voltage than the standard voltage regulator, while consuming significantly lower quiescent current. refer to section 27.0 electrical characteris- tics for the voltage output range of the retreg. this regulator is only used in sleep mode, and has limited output current to maintain the ram and provide power for limited peripherals, such as the wdt, while the device is in sleep. it is controlled by the retcfg con- figuration bit (fpor<2>) and in firmware by the reten bit (rcon<12>). retcfg must be programmed (= 0 ) and the reten bit must be set (= 1 ) for the retention regulator to be enabled. 10.4.4 retention sleep mode in retention sleep mode, the device is in sleep and all regulated voltage is provided solely by the retreg, while the main vreg is disabled. consequently, this mode provides the lowest sleep power consumption, but has a trade-off of a longer wake-up time. the low-voltage sleep wake-up time is longer than sleep mode due to the extra time required to re-enable the vreg and raise the v ddcore supply rail back to normal regulated levels. table 10-1: voltage regulati on configuration settings for pic24fxxxxx family devices note: the pic24f16km204 family devices do not have any internal voltage regulation, and therefore, do not support retention sleep mode. retcfg bit (fpor<2>) reten bit (rcon<12> pmslp bit (rcon<8>) power mode during sleep description 001 sleep vreg mode (normal) is unchanged during sleep. retreg is unused. 000 sleep vreg goes to low-power standby mode during sleep. (standby) retreg is unused. 010 retention sleep vreg is off during sleep. retreg is enabled and provides sleep voltage regulation. 1x1 sleep vreg mode (normal) is unchanged during sleep. retreg is disabled at all times. 1x0 sleep vreg goes to low-power standby mode during sleep. (standby) retreg is disabled at all times. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 135 pic24fv16km204 family 10.5 doze mode generally, changing clock speed and invoking one of the power-saving modes are the preferred strategies for reducing power consumption. there may be circumstances, however, where this is not practical. for example, it may be necessary for an application to maintain uninterrupted synchronous communication, even while it is doing nothing else. reducing system clock speed may introduce communication errors, while using a power-saving mode may stop communications completely. doze mode is a simple and effective alternative method to reduce power consumption while the device is still executing code. in this mode, the system clock contin- ues to operate from the same source and at the same speed. peripheral modules continue to be clocked at the same speed, while the cpu clock speed is reduced. synchronization between the two clock domains is maintained, allowing the peripherals to access the sfrs while the cpu executes code at a slower rate. doze mode is enabled by setting the dozen bit (clkdiv<11>). the ratio between peripheral and core clock speed is determined by the doze<2:0> bits (clkdiv<14:12>). there are eight possible configurations, from 1:1 to 1:128, with 1:1 being the default. it is also possible to use doze mode to selectively reduce power consumption in event driven applica- tions. this allows clock-sensitive functions, such as synchronous communications, to continue without interruption. meanwhile, the cpu idles, waiting for something to invoke an interrupt routine. enabling the automatic return to full-speed cpu operation on inter- rupts is enabled by setting the roi bit (clkdiv<15>). by default, interrupt events have no effect on doze mode operation. 10.6 selective peripheral module control idle and doze modes allow users to substantially reduce power consumption by slowing or stopping the cpu clock. even so, peripheral modules still remain clocked, and thus, consume power. there may be cases where the application needs what these modes do not provide: the allocation of power resources to cpu processing with minimal power consumption from the peripherals. pic24f devices address this requirement by allowing peripheral modules to be selectively disabled, reducing or eliminating their power consumption. this can be done with two control bits: the peripheral enable bit, generically named, xxxen, located in the modules main control sfr. the peripheral module disable (pmd) bit, generically named, xxxmd, located in one of the pmdx control registers. both bits have similar functions in enabling or disabling its associated module. setting the pmdx bits for a module, disables all clock sources to that module, reduc- ing its power consumption to an absolute minimum. in this state, the control and status registers associated with the peripheral will also be disabled, so writes to those registers will have no effect, and read values will be invalid. many peripheral modules have a corresponding pmdx bit. in contrast, disabling a module by clearing its xxxen bit, disables its functionality, but leaves its registers available to be read and written to. power consumption is reduced, but not by as much as when the pmdx bits are used. most peripheral modules have an enable bit; exceptions include capture, compare and rtcc. to achieve more selective power savings, peripheral modules can also be selectively disabled when the device enters idle mode. this is done through the control bit of the generic name format, xxxidl. by default, all modules that can operate during idle mode will do so. using the disable on idle feature disables the module while in idle mode, allowing further reduction of power consumption during idle mode, enhancing power savings for extremely critical power applications. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 136 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 137 pic24fv16km204 family 11.0 i/o ports all of the device pins (except v dd and v ss ) are shared between the peripherals and the parallel i/o ports. all i/o input ports feature schmitt trigger inputs for improved noise immunity. 11.1 parallel i/o (pio) ports a parallel i/o port that shares a pin with a peripheral is, in general, subservient to the peripheral. the peripherals output buffer data and control signals are provided to a pair of multiplexers. the multiplexers select whether the peripheral or the associated port has ownership of the output data and control signals of the i/o pin. the logic also prevents loop through, in which a ports digital output can drive the input of a peripheral that shares the same pin. figure 11-1 illustrates how ports are shared with other peripherals and the associated i/o pin to which they are connected. when a peripheral is enabled and the peripheral is actively driving an associated pin, the use of the pin as a general purpose output pin is disabled. the i/o pin may be read, but the output driver for the parallel port bit will be disabled. if a peripheral is enabled, but the peripheral is not actively driving a pin, that pin may be driven by a port. all port pins have three registers directly associated with their operation as digital i/o. the data direction register (trisx) determines whether the pin is an input or an output. if the data direction register bit is a 1 , then the pin is an input. all port pins are defined as inputs after a reset. reads from the data latch regis- ter (latx), read the latch. writes to the latch, write the latch. reads from the port (portx), read the port pins; writes to the port pins, write the latch. any bit and its associated data and control registers that are not valid for a particular device will be disabled. that means the corresponding latx and trisx registers, and the port pin will read as zeros. when a pin is shared with another peripheral or function that is defined as an input only, it is nevertheless regarded as a dedicated port because there is no other competing source of outputs. figure 11-1: block diagram of a typical shared port structure note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the i/o ports, refer to the pic24f family reference manual , i/o ports with peripheral pin select (pps) (ds39711). note that the pic24fv16km204 family devices do not support peripheral pin select features. q d ck wr lat + tris latch i/o pin wr port data bus q d ck data latch read port read tris 10 1 0 wr tris peripheral output data peripheral input data i/o peripheral module peripheral output enable pio module output multiplexers output data input data peripheral module enable read lat output enable downloaded from: http:///
pic24fv16km204 family ds30003030b-page 138 ? 2013 microchip technology inc. 11.1.1 open-drain configuration in addition to the port, lat and tris registers for data control, each port pin can also be individually con- figured for either digital or open-drain output. this is controlled by the open-drain control register, odcx, associated with each port. setting any of the bits configures the corresponding pin to act as an open-drain output. the maximum open-drain voltage allowed is the same as the maximum v ih specification. 11.2 configuring analog port pins the use of the ansx and trisx registers controls the operation of the a/d port pins. the port pins that are desired as analog inputs must have their correspond- ing trisx bit set (input). if the trisx bit is cleared (output), the digital output level (v oh or v ol ) will be converted. when reading the portx register, all pins configured as analog input channels will read as cleared (a low level). analog levels on any pin that is defined as a dig- ital input (including the anx pins) may cause the input buffer to consume current that exceeds the device specifications. 11.2.1 analog selection register i/o pins with shared analog functionality, such as a/d inputs and comparator inputs, must have their digital inputs shut off when analog functionality is used. note that analog functionality includes an analog voltage being applied to the pin externally. to allow for analog control, the ansx registers are provided. there is one ansx register for each port (ansa, ansb and ansc). within each ansx register, there is a bit for each pin that shares analog functionality with the digital i/o functionality. if a particular pin does not have an analog function, that bit is unimplemented. see register 11-1 to register 11-3 for implementation. register 11-1: ansa: porta analog selection register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 ansa4 ( 1 ) ansa3 ansa2 ansa1 ansa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-5 unimplemented: read as 0 bit 4-0 ansa<4:0>: analog select control bits ( 1 ) 1 = digital input buffer is not active (use for analog input) 0 = digital input buffer is active note 1: the ansa4 bit is not available on 20-pin devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 139 pic24fv16km204 family register 11-2: ansb: portb analog selection register r/w-1 r/w-1 r/w-1 r/w-1 u-0 u-0 r/w-1 r/w-1 ansb15 ansb14 ansb13 ansb12 ansb9 ansb8 bit 15 bit 8 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 ansb7 ansb6 ( 1 ) ansb5 ( 1 ) ansb4 ansb3 ( 1 ) ansb2 ansb1 ansb0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-12 ansb<15:12>: analog select control bits 1 = digital input buffer is not active (use for analog input) 0 = digital input buffer is active bit 11-10 unimplemented: read as 0 bit 9-0 ansb<9:0>: analog select control bits ( 1 ) 1 = digital input buffer is not active (use for analog input) 0 = digital input buffer is active note 1: the ansb<6:5,3> bits are not available on 20-pin devices. register 11-3: ansc: portc analog selection register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r/w-1 r/w-1 r/w-1 ansc2 ( 1 , 2 ) ansc1 ( 1 , 2 ) ansc0 ( 1 , 2 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-3 unimplemented: read as 0 bit 2-0 ansc<2:0>: analog select control bits ( 1 , 2 ) 1 = digital input buffer is not active (use for analog input) 0 = digital input buffer is active note 1: these bits are not implemented in 20-pin devices. 2: these bits are not implemented in 28-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 140 ? 2013 microchip technology inc. 11.2.2 i/o port write/read timing one instruction cycle is required between a port direction change or port write operation, and a read operation of the same port. typically, this instruction would be a nop . 11.3 input change notification (icn) the input change notification function of the i/o ports allows the pic24fxxxxx family of devices to generate interrupt requests to the processor in response to a change-of-state (cos) on selected input pins. this feature is capable of detecting input change-of-states, even in sleep mode, when the clocks are disabled. depending on the device pin count, there are up to 37 external signals (cn0 through cn36) that may be selected (enabled) for generating an interrupt request on a change-of-state. there are six control registers associated with the cn module. the cnen1 and cnen3 registers contain the interrupt enable control bits for each of the cnx input pins. setting any of these bits enables a cn interrupt for the corresponding pins. each cnx pin also has a weak pull-up/pull-down connected to it. the pull-ups act as a current source that is connected to the pin. the pull-downs act as a current sink to eliminate the need for external resistors when push button or keypad devices are connected. on any pin, only the pull-up resistor or the pull-down resistor should be enabled, but not both of them. if the push button or the keypad is connected to v dd , enable the pull-down, or if they are connected to v ss , enable the pull-up resistors. the pull-ups are enabled separately using the cnpu1 and cnpu3 registers, which contain the control bits for each of the cnx pins. setting any of the control bits enables the weak pull-ups for the corresponding pins. the pull-downs are enabled separately using the cnpd1 and cnpd3 registers, which contain the control bits for each of the cnx pins. setting any of the control bits enables the weak pull-downs for the corresponding pins. when the internal pull-up is selected, the pin uses v dd as the pull-up source voltage. when the internal pull-down is selected, the pins are pulled down to v ss by an internal resistor. make sure that there is no external pull-up source/pull-down sink when the internal pull-ups/pull-downs are enabled. example 11-1: port write/read example note: pull-ups and pull-downs on change notifi- cation (cn) pins should always be disabled whenever the port pin is configured as a digital output. mov 0xff00, w0; //configure portb<15:8> as inputs and portb<7:0> as outputs mov w0, trisb; nop; //delay 1 cycle btss portb, #13; //next instruction equivalent c code trisb = 0xff00; //configure portb<15:8> as inputs and portb<7:0> as outputs nop(); //delay 1 cycle if(portbbits.rb13 == 1) // execute following code if portb pin 13 is set. { } downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 141 pic24fv16km204 family 12.0 timer1 the timer1 module is a 16-bit timer which can serve as the time counter for the real-time clock (rtc) or operate as a free-running, interval timer/counter. timer1 can operate in three modes: 16-bit timer 16-bit synchronous counter 16-bit asynchronous counter timer1 also supports these features: timer gate operation selectable prescaler settings timer operation during cpu idle and sleep modes interrupt on 16-bit period register match or falling edge of external gate signal figure 12-1 illustrates a block diagram of the 16-bit timer1 module. to configure timer1 for operation: 1. set the ton bit (= 1 ). 2. select the timer prescaler ratio using the tckps<1:0> bits. 3. set the clock and gating modes using the tcs and tgate bits. 4. set or clear the tsync bit to configure synchronous or asynchronous operation. 5. load the timer period value into the pr1 register. 6. if interrupts are required, set the timer1 interrupt enable bit, t1ie. use the timer1 interrupt priority bits, t1ip<2:0>, to set the interrupt priority. figure 12-1: 16-bit time r1 module block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on timers, refer to the pic24f family reference manual , timers (ds39704). ton sync sosci sosco pr1 set t1if equal reset soscen tsync q qd ck tckps<1:0> prescaler 1, 8, 64, 256 2 tgate f osc /2 tcs tgate t1ck tecs<1:0> lprc comparator tmr1 gate sync downloaded from: http:///
pic24fv16km204 family ds30003030b-page 142 ? 2013 microchip technology inc. register 12-1: t1con: ti mer1 control register r/w-0 u-0 r/w-0 u-0 u-0 u-0 r/w-0 r/w-0 ton t s i d l tecs1 ( 1 ) tecs0 ( 1 ) bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 u-0 tgate tckps1 tckps0 t s y n ct c s bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 ton: timer1 on bit 1 = starts 16-bit timer1 0 = stops 16-bit timer1 bit 14 unimplemented: read as 0 bit 13 tsidl: timer1 stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12-10 unimplemented: read as 0 bit 9-8 tecs<1:0>: timer1 extended clock select bits ( 1 ) 11 = reserved; do not use 10 = timer1 uses the lprc as the clock source 01 = timer1 uses the external clock (ec) from t1ck 00 = timer1 uses the secondary oscillator (sosc) as the clock source bit 7 unimplemented: read as 0 bit 6 tgate: timer1 gated time accumulation enable bit when tcs = 1 : this bit is ignored. when tcs = 0 : 1 = gated time accumulation is enabled 0 = gated time accumulation is disabled bit 5-4 tckps<1:0>: timer1 input clock prescale select bits 11 = 1:256 10 = 1:64 01 = 1:8 00 = 1:1 bit 3 unimplemented: read as 0 bit 2 tsync: timer1 external clock input synchronization select bit when tcs = 1 : 1 = synchronizes external clock input 0 = does not synchronize external clock input when tcs = 0 : this bit is ignored. bit 1 tcs: timer1 clock source select bit 1 = timer1 clock source is selected by tecs<1:0> 0 = internal clock (f osc /2) bit 0 unimplemented: read as 0 note 1: the tecsx bits are valid only when tcs = 1 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 143 pic24fv16km204 family 13.0 capture/compare/pwm/ timer modules (mccp and sccp) pic24fv16km204 family devices include several capture/compare/pwm/timer base modules, which provide the functionality of three different peripherals of earlier pic24f devices. the module can operate in one of three major modes: general purpose timer input capture output compare/pwm the module is provided in two different forms, distin- guished by the number of pwm outputs that the module can generate. single output modules (sccps) provide only one pwm output. multiple output modules (mccps) can provide up to six outputs and an extended range of power control features, depending on the pin count of the particular device. all other features of the modules are identical. the sccp and mccp modules can be operated only in one of the three major modes at any time. the other modes are not available unless the module is reconfigured for the new mode. a conceptual block diagram for the module is shown in figure 13-1 . all three modes share a time base gener- ator and a common timer register pair (ccpxtmrh/l); other shared hardware components are added as a particular mode requires. each module has a total of seven control and status registers: ccpxcon1l ( register 13-1 ) ccpxcon1h ( register 13-2 ) ccpxcon2l ( register 13-3 ) ccpxcon2h ( register 13-4 ) ccpxcon3l ( register 13-5 ) ccpxcon3h ( register 13-6 ) ccpxstatl ( register 13-7 ) each module also includes eight buffer/counter regis- ters that serve as timer value registers or data holding buffers: ccpxtmrh/ccpxtmrl (timer high/low counters) ccpxprh/ccpxprl (timer period high/low) ccpxra (primary output compare data buffer) ccpxrb (secondary output compare data buffer) ccpxbufh/ccpxbufl (input capture high/low buffers) figure 13-1: mccpx/sccpx co nceptual block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive refer- ence source. for more information on the mccp/sccp modules, refer to the pic24f family reference manual . clock sources input capture output compare/ pwm t32 ccsel mod<3:0> sync and gating sources 16/32-bit auxiliary output (to ctmu) ccpxif cctxif external compare/pwm output(s) oefa/oefb timer sync/trigger out special trigger (to a/d) capture input time base generator ccpxtmrh/l downloaded from: http:///
pic24fv16km204 family ds30003030b-page 144 ? 2013 microchip technology inc. 13.1 time base generator the timer clock generator (tcg) generates a clock for the modules internal time base, using one of the clock signals already available on the microcontroller. this is used as the time reference for the module in its three major modes. the internal time base is shown in figure 13-2 . there are eight inputs available to the clock generator, which are selected using the clksel<2:0> bits (ccpxcon1l<10:8>). available sources include the frc and lprc, the secondary oscillator, and the tclki external clock inputs. the system clock is the default source (clksel<2:0> = 000 ). on pic24fv16km204 family devices, clock sources to the mccpx module must be synchronized with the system clock; as a result, when clock sources are selected, clock input timing restrictions or module operating restrictions may exist. ta b l e 1 3 - 1 describes which time base sources are valid for the various operating modes. table 13-1: valid timer options for mccpx/sccpx modes figure 13-2: timer clock generator clksel <2:0> ( 1 ) timer input capture output compare sync ( 2 ) async ( 3 ) 111 x 110 x 101 x 011 x 010 x 001 x 000 ( 4 ) xx x note 1: see register 13-1 for the description of the time base sources. 2: synchronous operation: tmrsync (ccpxcon1l<11>) = 1 and trigen (ccpxcon1h<7>) = 0 . 3: asynchronous operation: (tmrsync = 0 ) or triggered mode (trigen = 1 ). 4: when clksel<2:0> = 000 , the tmrsync bit must be cleared. clksel<2:0> tmrps<1:0> prescaler clock synchronizer tmrsync gate (1) ssdg clock sources to r e s t of module note 1: gating available in timer modes only. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 145 pic24fv16km204 family 13.2 general purpose timer timer mode is selected when ccsel = 0 and mod<3:0> = 0000 . the timer can function as a 32-bit timer or a dual 16-bit timer, depending on the setting of the t32 bit ( table 13-2 ). table 13-2: timer operation mode dual 16-bit timer mode provides a simple timer func- tion with two independent 16-bit timer/counters. the primary timer uses ccpxtmrl and ccpxprl. only the primary timer can interact with other modules on the device. it generates the mccpx sync out signals for use by other mccp modules. it can also use the sync<4:0> bits signal generated by other modules. the secondary timer uses ccpxtmrh and ccpxprh. it is intended to be used only as a periodic interrupt source for scheduling cpu events. it does not generate an output sync/trigger signal like the primary time base. in dual timer mode, the secondary timer period regis- ter, ccpxprh, generates the mccp compare event (ccpxif) used by many other modules on the device. the 32-bit timer mode uses the ccpxtmrl and ccpxtmrh registers, together, as a single 32-bit timer. when ccpxtmrl overflows, ccpxtmrh increments by one. this mode provides a simple timer function when it is important to track long time periods. note that the t32 bit (ccpxcon1l<5>) should be set before the ccpxtmrl or ccpxprh registers are written to initialize the 32-bit timer. 13.2.1 sync and trigger operation in both 16-bit and 32-bit modes, the timer can also function in either synchronization (sync) or trigger operation. both use the sync<4:0> bits (ccpxcon1h<4:0>) to determine the input signal source. the difference is how that signal affects the timer. in sync operation, the timer reset or clear occurs when the input selected by sync<4:0> is asserted. the timer immediately begins to count again from zero unless it is held for some other reason. sync operation is used whenever the trigen bit (ccpxcon1h<7>) is cleared. sync<4:0> can have any value except 11111 . in trigger operation, the timer is held in reset until the input selected by sync<4:0> is asserted; when it occurs, the timer starts counting. trigger operation is used whenever the trigen bit is set. in trigger mode, the timer will continue running after a trigger event as long as the ccptrig bit (ccpxstatl< 7>) is set. to clear ccptrig, the trclr bit (ccpxstatl<5>) must be set to clear the trigger event, reset the timer and hold it at zero until another trigger event occurs. on pic24fv16km204 family devices, trigger operation can only be used when the system clock is the time base source (clksel<2:0> = 000 ). figure 13-3: dual 16-bit timer mode t32 (ccpxcon1l<5>) operating mode 0 dual timer mode (16-bit) 1 timer mode (32-bit) comparator ccpxtmrl ccpxprl ccpxrb ccpxtmrh ccpxprh comparator clock sources set cctxif special event trigger set ccpxif sync<4:0> time base generator sync/ trigger control comparator downloaded from: http:///
pic24fv16km204 family ds30003030b-page 146 ? 2013 microchip technology inc. figure 13-4: 32-bit timer mode ccpxtmrl ccpxprl comparator set cctxif ccpxtmrh ccpxprh clock sources sync/ trigger control sync<4:0> time base generator downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 147 pic24fv16km204 family 13.3 output compare mode output compare mode compares the timer register value with the value of one or two compare registers, depending on its mode of operation. the output com- pare x module on compare match events has the ability to generate a single output transition or a train of output pulses. like most pic ? mcu peripherals, the output compare x module can also generate interrupts on a compare match event. table 13-3 shows the various modes available in output compare modes. table 13-3: output compare/pwm modes figure 13-5: output compare x block diagram mod<3:0> (ccpxcon1l<3:0>) t32 (ccpxcon1l<5>) operating mode 0001 0 output high on compare (16-bit) single edge mode 0001 1 output high on compare (32-bit) 0010 0 output low on compare (16-bit) 0010 1 output low on compare (32-bit) 0011 0 output toggle on compare (16-bit) 0011 1 output toggle on compare (32-bit) 0100 0 dual edge compare (16-bit) dual edge mode 0101 0 dual edge compare (16-bit buffered) pwm mode 0110 0 center-aligned pulse (16-bit buffered) center pwm 0111 0 variable frequency pulse (16-bit) 0111 1 variable frequency pulse (32-bit) ccpxra buffer comparator ccpxcon1h/l ccpxcon2h/l ocx output, output compare ccpx pin(s) ccpxrb buffer comparator fault logic match match time base generator increment reset ocx clock sources trigger and sync sources reset match event ocfa/ocfb ccpxra event event rollover rollover/reset rollover/reset ccpxcon3h/l auto-shutdown and polarity control edge detect interrupt comparator trigger and sync logic ccpxprl ccpxrb ccpxtmrh/l downloaded from: http:///
pic24fv16km204 family ds30003030b-page 148 ? 2013 microchip technology inc. 13.4 input capture mode input capture mode is used to capture a timer value from an independent timer base upon an event on an input pin or other internal trigger source. the input capture features are useful in applications requiring frequency (time period) and pulse measurement. figure 13-6 depicts a simplified block diagram of input capture mode. input capture mode uses a dedicated 16/32-bit, synchro- nous, up counting timer for the capture function. the timer value is written to the fifo when a capture event occurs. the internal value may be read (with a synchronization delay) using the ccpxtmrh/l register. to use input capture mode, the ccsel bit (ccpxcon1l<4>) must be set. the t32 and the mod<3:0> bits are used to select the proper capture mode, as shown in tab le 1 3- 4 . figure 13-6: input capture x block diagram table 13-4: input capture modes mod<3:0> (ccpxcon1l<3:0>) t32 (ccpxcon1l<5>) operating mode 0000 0 edge detect (16-bit capture) 0000 1 edge detect (32-bit capture) 0001 0 every rising (16-bit capture) 0001 1 every rising (32-bit capture) 0010 0 every falling (16-bit capture) 0010 1 every falling (32-bit capture) 0011 0 every rise/fall (16-bit capture) 0011 1 every rise/fall (32-bit capture) 0100 0 every 4th rising (16-bit capture) 0100 1 every 4th rising (32-bit capture) 0101 0 every 16th rising (16-bit capture) 0101 1 every 16th rising (32-bit capture) ccpxbufx 4-level fifo buffer mod<3:0> set ccpxif ops<3:0> interrupt logic system bus event and trigger and sync logic clock select ic clock sources trigger and sync sources ic<2:0> 16 16 16 ccpxtmrh/l increment reset t32 edge detect logic and clock synchronizer downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 149 pic24fv16km204 family 13.5 auxiliary output the mccpx and sccpx modules have an auxiliary (secondary) output that provides other peripherals access to internal module signals. the auxiliary output is intended to connect to other mccp or sccp modules, or other digital peripherals, to provide these types of functions: time base synchronization peripheral trigger and clock inputs signal gating the type of output signal is selected using the auxout<1:0> control bits (ccpxcon2h<4:3>). the type of output signal is also dependent on the module operating mode. on the pic24fv16km204 family of devices, only the ctmu discharge trigger has access to the auxiliary output signal. table 13-5: auxiliary output auxout<1:0> ccsel mod<3:0> comments signal description 00 x xxxx auxiliary output disabled no output 01 0 0000 time base modes time base period reset or rollover 10 special event trigger output 11 no output 01 0 0001 through 1111 output compare modes time base period reset or rollover 10 output compare event signal 11 output compare signal 01 1 xxxx input capture modes time base period reset or rollover 10 reflects the value of the icdis bit 11 input capture event signal downloaded from: http:///
pic24fv16km204 family ds30003030b-page 150 ? 2013 microchip technology inc. register 13-1: ccpxcon1l: ccpx control 1 low registers r/w-0 u-0 r/w-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 ccpon ccpsidl r tmrsync clksel2 ( 1 ) clksel1 ( 1 ) clksel0 ( 1 ) bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 tmrps1 tmrps0 t32 ccsel mod3 mod2 mod1 mod0 bit 7 bit 0 legend: r = reserved bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 ccpon: ccpx module enable bit 1 = module is enabled with an operating mode specified by the mod<3:0> control bits 0 = module is disabled bit 14 unimplemented: read as 0 bit 13 ccpsidl: ccpx stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12 reserved: maintain as 0 bit 11 tmrsync: time base clock synchronization bit 1 = asynchronous module time base clock is selected and synchronized to the internal system clocks (clksel<2:0> ? 000 ) 0 = synchronous module time base clock is selected and does not require synchronization (clksel<2:0> = 000 ) bit 10-8 clksel<2:0>: ccpx time base clock select bits ( 1 ) 111 = external tclkia input 110 = external tclkib input 101 = clc1 100 = reserved 011 = lprc (31 khz source) 010 = secondary oscillator 001 = reserved 000 = system clock (t cy ) bit 7-6 tmrps<1:0>: time base prescale select bits 11 = 1:64 prescaler 10 = 1:16 prescaler 01 = 1:4 prescaler 00 = 1:1 prescaler bit 5 t32: 32-bit time base select bit 1 = uses 32-bit time base for timer, single edge output compare or input capture function 0 = uses 16-bit time base for timer, single edge output compare or input capture function bit 4 ccsel: capture/compare mode select bit 1 = input capture peripheral 0 = output compare/pwm/timer peripheral (exact function is selected by the mod<3:0> bits) note 1: clock options are limited in some operating modes. see table 13-1 for restrictions. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 151 pic24fv16km204 family bit 3-0 mod<3:0>: ccpx mode select bits for ccsel = 1 (input capture modes): 1xxx = reserved 011x = reserved 0101 = capture every 16th rising edge 0100 = capture every 4th rising edge 0011 = capture every rising and falling edge 0010 = capture every falling edge 0001 = capture every rising edge 0000 = capture every rising and falling edge (edge detect mode) for ccsel = 0 (output compare/timer modes): 1111 = external input mode: pulse generator is disabled, source is selected by ics<2:0> 1110 = reserved 110x = reserved 10xx = reserved 0111 = variable frequency pulse mode 0110 = center-aligned pulse compare mode, buffered 0101 = dual edge compare mode, buffered 0100 = dual edge compare mode 0011 = 16-bit/32-bit single edge mode, toggle output on compare match 0010 = 16-bit/32-bit single edge mode, drive output low on compare match 0001 = 16-bit/32-bit single edge mode, drive output high on compare match 0000 = 16-bit/32-bit timer mode, output functions are disabled register 13-1: ccpxcon1l: ccpx cont rol 1 low registers (continued) note 1: clock options are limited in some operating modes. see table 13-1 for restrictions. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 152 ? 2013 microchip technology inc. register 13-2: ccpxcon1h: ccpx control 1 high registers r/w-0 r/w-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 opssrc ( 1 ) rtrgen ( 2 ) ops3 ( 3 ) ops2 ( 3 ) ops1 ( 3 ) ops0 ( 3 ) bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 trigen ( 4 ) oneshot altsync sync4 sync3 sync2 sync1 sync0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 opssrc: output postscaler source select bit ( 1 ) 1 = output postscaler scales module trigger output events 0 = output postscaler scales time base interrupt events bit 14 rtrgen: retrigger enable bit ( 2 ) 1 = time base can be retriggered when trigen bit = 1 0 = time base may not be retriggered when trigen bit = 1 bit 13-12 unimplemented: read as 0 bit 11-8 ops3<3:0>: ccpx interrupt output postscale select bits ( 3 ) 1111 = interrupt every 16th time base period match 1110 = interrupt every 15th time base period match . . . 0100 = interrupt every 5th time base period match 0011 = interrupt every 4th time base period match or 4th input capture event 0010 = interrupt every 3rd time base period match or 3rd input capture event 0001 = interrupt every 2nd time base period match or 2nd input capture event 0000 = interrupt after each time base period match or input capture event bit 7 trigen: ccpx trigger enable bit ( 4 ) 1 = trigger operation of time base is enabled 0 = trigger operation of time base is disabled bit 6 oneshot: one-shot mode enable bit 1 = one-shot trigger mode is enabled; trigger duration is set by oscnt<2:0> 0 = one-shot trigger mode is disabled bit 5 altsync: ccpx clock select bits 1 = an alternate signal is used as the module synchronization output signal 0 = the module synchronization output signal is the time base reset/rollover event bit 4-0 sync<4:0>: ccpx synchronization source select bits see table 13-6 for the definition of inputs. note 1: this control bit has no function in input capture modes. 2: this control bit has no function when trigen = 0 . 3: output postscale settings from 1:5 to 1:16 ( 0100 - 1111 ) will result in a fifo buffer overflow for input capture modes. 4: clock source options are limited when trigger operation is enabled; refer to tab l e 1 3- 1 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 153 pic24fv16km204 family table 13-6: synchronization sources sync<4:0> synchronization source 00000 none; timer with rollover on ccpxpr match or ffffh 00001 mccp1 or sccp1 sync output 00010 mccp2 or sccp2 sync output 00011 mccp3 or sccp3 sync output 00100 mccp4 or sccp4 sync output 00101 mccp5 or sccp5 sync output 00110 to 01010 unused 01011 timer1 sync output ( 1 ) 01100 to 10000 unused 10001 clc1 output ( 1 ) 10010 clc2 output ( 1 ) 10011 to 11010 unused 11011 a/d ( 1 ) 11110 unused 11111 none; timer with auto-rollover (ffffh 0000h) note 1: these sources are only available when the source module is being used in a synchronous mode. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 154 ? 2013 microchip technology inc. table 13-7: auto-shutdown and gating sources register 13-3: ccpxcon2l: ccpx control 2 low registers r/w-0 r/w-0 u-0 r/w-0 u-0 u-0 u-0 u-0 pwmrsen asdgm ssdg bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 asdg7 asdg6 asdg5 asdg4 asdg3 asdg2 asdg1 asdg0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 pwmrsen: ccpx pwm restart enable bit 1 = asevt bit clears automatically at the beginning of the next pwm period, after the shutdown input has ended 0 = asevt bit must be cleared in software to resume pwm activity on output pins bit 14 asdgm: ccpx auto-shutdown gate mode enable bit 1 = wait until the next time base reset or rollover for shutdown to occur 0 = shutdown event occurs immediately bit 13 unimplemented: read as 0 bit 12 ssdg: ccpx software shutdown/gate control bit 1 = manually force auto-shutdown, timer clock gate or input capture signal gate event (setting of asdgm bit still applies) 0 = normal module operation bit 11-8 unimplemented: read as 0 bit 7-0 asdg<7:0>: ccpx auto-shutdown/gating source enable bits 1 = asdgx source n is enabled (see tab l e 1 3- 7 for auto-shutdown/gating sources) 0 = asdgx source n is disabled asdg<7:0> bits auto-shutdown/gating source 0 comparator 1 output 1 comparator 2 output 2 comparator 3 output 3 sccp4 output compare 4 sccp5 output compare 5 clc1 output 6 ocfa fault input 7 ocfb fault input downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 155 pic24fv16km204 family register 13-4: ccpxcon2h: ccpx control 2 high registers r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 oensync o c f e n ( 1 ) oceen ( 1 ) ocden ( 1 ) occen ( 1 ) ocben ( 1 ) ocaen bit 15 bit 8 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 icgsm1 icgsm0 auxout1 auxout0 ics2 ics1 ics0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 oensync: output enable synchronization bit 1 = update by output enable bits occurs on the next time base reset or rollover 0 = update by output enable bits occurs immediately bit 14 unimplemented: read as 0 bit 13-8 ocen: output enable/steering control bits ( 1 ) 1 = ocx pin is controlled by the ccpx module and produces an output compare or pwm signal 0 = ocx pin is not controlled by the ccpx module; the pin is available to the port logic or another peripheral multiplexed on the pin bit 7-6 icgsm<1:0>: input capture gating source mode control bits 11 = reserved 10 = one-shot mode: falling edge from gating source disables future capture events (icdis = 1 ) 01 = one-shot mode: rising edge from gating source enables future capture events (icdis = 0 ) 00 = level-sensitive mode: a high level from gating source will enable future capture events; a low level will disable future capture events bit 5 unimplemented: read as 0 bit 4-3 auxout<1:0>: auxiliary output signal on event selection bits 11 = input capture or output compare event; no signal in timer mode 10 = signal output is defined by module operating mode (see table 13-5 ) 01 = time base rollover event (all modes) 00 =disabled bit 2-0 ics<2:0>: input capture source select bits 111 = unused 110 = clc2 output 101 = clc1 output 100 = unused 011 = comparator 3 output 010 = comparator 2 output 001 = comparator 1 output 000 = input capture x (icx) i/o pin note 1: ocfen through ocben (bits<13:9>) are implemented in mccpx modules only. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 156 ? 2013 microchip technology inc. register 13-5: ccpxcon3l: ccpx control 3 low registers ( 1 ) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 dt5 dt4 dt3 dt2 dt1 dt0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-6 unimplemented: read as 0 bit 5-0 dt<5:0>: ccpx dead-time select bits 111111 = insert 63 dead-time delay periods between complementary output signals 111110 = insert 62 dead-time delay periods between complementary output signals . . . 000010 = insert 2 dead-time delay periods between complementary output signals 000001 = insert 1 dead-time delay period between complementary output signals 000000 = dead-time logic is disabled note 1: this register is implemented in mccpx modules only. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 157 pic24fv16km204 family register 13-6: ccpxcon3h: ccpx control 3 high registers r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 oetrig oscnt2 oscnt1 oscnt0 o u t m 2 ( 1 ) outm1 ( 1 ) outm0 ( 1 ) bit 15 bit 8 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 p o l a c e p o l b d f ( 1 ) pssace1 pssace0 pssbdf1 ( 1 ) pssbdf0 ( 1 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 oetrig: ccpx dead-time select bit 1 = for triggered mode (trigen = 1 ): module does not drive enabled output pins until triggered 0 = normal output pin operation bit 14-12 oscnt<2:0>: one-shot event count bits 111 = extend one-shot event by 7 time base periods (8 time base periods total) 110 = extend one-shot event by 6 time base periods (7 time base periods total) 101 = extend one-shot event by 5 time base periods (6 time base periods total) 100 = extend one-shot event by 4 time base periods (5 time base periods total) 011 = extend one-shot event by 3 time base periods (4 time base periods total) 010 = extend one-shot event by 2 time base periods (3 time base periods total) 001 = extend one-shot event by 1 time base period (2 time base periods total) 000 = do not extend one-shot trigger event bit 11 unimplemented: read as 0 bit 10-8 outm<2:0>: pwmx output mode control bits ( 1 ) 111 = reserved 110 = output scan mode 101 = brush dc output mode, forward 100 = brush dc output mode, reverse 011 = reserved 010 = half-bridge output mode 001 = push-pull output mode 000 = steerable single output mode bit 7-6 unimplemented: read as 0 bit 5 polace: ccpx output pins, ocxa, ocxc and ocxe, polarity control bit 1 = output pin polarity is active-low 0 = output pin polarity is active-high bit 4 polbdf: ccpx output pins, ocxb, ocxd and ocxf, polarity control bit ( 1 ) 1 = output pin polarity is active-low 0 = output pin polarity is active-high bit 3-2 pssace<1:0>: pwmx output pins, ocxa, ocxc and ocxe, shutdown state control bits 11 = pins are driven active when a shutdown event occurs 10 = pins are driven inactive when a shutdown event occurs 0x = pins are tri-stated when a shutdown event occurs bit 1-0 pssbdf<1:0>: pwmx output pins, ocxb, ocxd, and ocxf, shutdown state control bits ( 1 ) 11 = pins are driven active when a shutdown event occurs 10 = pins are driven inactive when a shutdown event occurs 0x = pins are in a high-impedance state when a shutdown event occurs note 1: these bits are implemented in mccpx modules only. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 158 ? 2013 microchip technology inc. register 13-7: ccpxstatl: ccpx status register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r-0 w1-0 w1-0 r/c-0 r/c-0 r/c-0 r/c-0 r/c-0 ccptrig trset trclr asevt scevt icdis icov icbne bit 7 bit 0 legend: c = clearable bit r = readable bit w1 = write 1 only u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 ccptrig: ccpx trigger status bit 1 = timer has been triggered and is running 0 = timer has not been triggered and is held in reset bit 6 trset: ccpx trigger set request bit write 1 to this location to trigger the timer when trigen = 1 (location always reads as 0 ). bit 5 trclr: ccpx trigger clear request bit write 1 to this location to cancel the timer trigger when trigen = 1 (location always reads as 0 ). bit 4 asevt: ccpx auto-shutdown event status/control bit 1 = a shutdown event is in progress; ccpx outputs are in the shutdown state 0 = ccpx outputs operate normally bit 3 scevt: single edge compare event status bit 1 = a single edge compare event has occurred 0 = a single edge compare event has not occurred bit 2 icdis: input capture x disable bit 1 = event on input capture x pin (icx) does not generate a capture event 0 = event on input capture x pin will generate a capture event bit 1 icov: input capture x buffer overflow status bit 1 = the input capture x fifo buffer has overflowed 0 = the input capture x fifo buffer has not overflowed bit 0 icbne: input capture x buffer status bit 1 = input capture x buffer has data available 0 = input capture x buffer is empty downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 159 pic24fv16km204 family 14.0 master synchronous serial port (mssp) the master synchronous serial port (mssp) module is an 8-bit serial interface, useful for communicating with other peripheral or microcontroller devices. these peripheral devices may be serial eeproms, shift reg- isters, display drivers, a/d converters, etc. the mssp module can operate in one of two modes: serial peripheral interface (spi) inter-integrated circuit (i 2 c?) - full master mode - slave mode (with general address call) the spi interface supports these modes in hardware: master mode slave mode daisy-chaining operation in slave mode synchronized slave operation the i 2 c interface supports the following modes in hardware: master mode multi-master mode slave mode with 10-bit and 7-bit addressing and address masking byte nacking selectable address and data hold, and interrupt masking 14.1 i/o pin configuration for spi in spi master mode, the mssp module will assert con- trol over any pins associated with the sdox and sckx outputs. this does not automatically disable other digi- tal functions associated with the pin and may result in the module driving the digital i/o port inputs. to prevent this, the mssp module outputs must be disconnected from their output pins while the module is in spi master mode. while disabling the module temporarily may be an option, it may not be a practical solution in all applications. the sdox and sckx outputs for the module can be selectively disabled by using the sdoxdis and sckxdis bits in the padcfg1 register ( register 14-10 ). setting the bit disconnects the corresponding output for a particular module from its assigned pin. note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on mssp, refer to the pic24f family reference manual . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 160 ? 2013 microchip technology inc. figure 14-1: msspx block diagram (spi mode) figure 14-2: spi mast er/slave connection ( ) read write internal data bus sspm<3:0> bit 0 shift clock ssx control enable edge select clock select tmr2 output t osc prescaler 4, 16, 64 2 edge select 2 4 data to tx/rx in sspxsr trisx bit 2 smp:cke sdox sdix ssx sckx note: refer to the device data sheet for pin multiplexing. sspxadd<7:0> 7 sspxbuf sspxsr baud rate generator serial input buffer (sspxbuf) shift register (sspxsr) msb lsb sdox sdix processor 1 sckx spi master sspm<3:0> = 00xx serial input buffer (sspxbuf) shift register (sspxsr) lsb msb sdix sdox processor 2 sckx spi slave sspm<3:0> = 010x serial clock downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 161 pic24fv16km204 family figure 14-3: msspx block diagram (i 2 c? mode) figure 14-4: msspx block diagram (i 2 c? master mode) match detect sspxadd internal data bus address match set/reset s, p bits shift clock msb lsb note: only port i/o names are shown in this diagram. refer to the text for a full list of multiplexed functions. sclx sdax start and stop bit detect read write sspxbuf sspxsr address mask start bit, stop bit, internal data bus set/reset s, p (sspxstat), wcol shift clock msb lsb sdax acknowledge generate stop bit detect write collision detect clock arbitration state counter for end of xmit/rcv sclx sclx in bus collision sdax in rcv enable clock cntl clock arbitrate/wcol detect (hold off clock source) sspxadd<6:0> baud set sspxif, bclxif reset ackstat, pen rate generator sspm<3:0> start bit detect sspxsr sspxbuf read write downloaded from: http:///
pic24fv16km204 family ds30003030b-page 162 ? 2013 microchip technology inc. register 14-1: sspxstat: msspx status register (spi mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke ( 1 ) d/a psr / w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 smp: sample bit spi master mode: 1 = input data is sampled at the end of data output time 0 = input data is sampled at the middle of data output time spi slave mode: smp must be cleared when spi is used in slave mode. bit 6 cke: spi clock select bit ( 1 ) 1 = transmit occurs on transition from active to idle clock state 0 = transmit occurs on transition from idle to active clock state bit 5 d/a : data/address bit used in i 2 c? mode only. bit 4 p: stop bit used in i 2 c mode only. this bit is cleared when the msspx module is disabled; sspen bit is cleared. bit 3 s: start bit used in i 2 c mode only. bit 2 r/w : read/write information bit used in i 2 c mode only. bit 1 ua: update address bit used in i 2 c mode only. bit 0 bf: buffer full status bit 1 = receive is complete, sspxbuf is full 0 = receive is not complete, sspxbuf is empty note 1: polarity of clock state is set by the ckp bit (sspxcon1<4>). downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 163 pic24fv16km204 family register 14-2: sspxstat: msspx status register (i 2 c? mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r-0 r-0 r-0 r-0 r-0 r-0 smp cke d/a p ( 1 ) s ( 1 ) r/w ua bf bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 smp: slew rate control bit in master or slave mode: 1 = slew rate control is disabled for standard speed mode (100 khz and 1 mhz) 0 = slew rate control is enabled for high-speed mode (400 khz) bit 6 cke: smbus select bit in master or slave mode: 1 = enables smbus-specific inputs 0 = disables smbus-specific inputs bit 5 d/a : data/address bit in master mode: reserved. in slave mode: 1 = indicates that the last byte received or transmitted was data 0 = indicates that the last byte received or transmitted was address bit 4 p: stop bit ( 1 ) 1 = indicates that a stop bit has been detected last 0 = stop bit was not detected last bit 3 s: start bit ( 1 ) 1 = indicates that a start bit has been detected last 0 = start bit was not detected last bit 2 r/w : read/write information bit in slave mode: ( 2 ) 1 = read 0 = write in master mode: ( 3 ) 1 = transmit is in progress 0 = transmit is not in progress bit 1 ua: update address bit (10-bit slave mode only) 1 = indicates that the user needs to update the address in the sspxadd register 0 = address does not need to be updated note 1: this bit is cleared on reset and when sspen is cleared. 2: this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit or not ack bit. 3: oring this bit with sen, rsen, pen, rcen or acken w ill indicate if the msspx is in active mode. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 164 ? 2013 microchip technology inc. bit 0 bf: buffer full status bit in transmit mode: 1 = transmit is in progress, sspxbuf is full 0 = transmit is complete, sspxbuf is empty in receive mode: 1 = sspxbuf is full (does not include the ack and stop bits) 0 = sspxbuf is empty (does not include the ack and stop bits) register 14-2: sspxstat: msspx status register (i 2 c? mode) (continued) note 1: this bit is cleared on reset and when sspen is cleared. 2: this bit holds the r/w bit information following the last address match. this bit is only valid from the address match to the next start bit, stop bit or not ack bit. 3: oring this bit with sen, rsen, pen, rcen or acken w ill indicate if the msspx is in active mode. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 165 pic24fv16km204 family register 14-3: sspxcon1: msspx co ntrol register 1 (spi mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov ( 1 ) sspen ( 2 ) ckp sspm3 ( 3 ) sspm2 ( 3 ) sspm1 ( 3 ) sspm0 ( 3 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 wcol: write collision detect bit 1 = the sspxbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision bit 6 sspov: master synchronous serial port receive overflow indicator bit ( 1 ) spi slave mode: 1 = a new byte is received while the sspxbuf register is still holding the previous data. in case of over- flow, the data in sspxsr is lost. overflow can onl y occur in slave mode. the user must read the sspxbuf, even if only transmitting data, to avoid setting overflow (must be cleared in software). 0 = no overflow bit 5 sspen: master synchronous serial port enable bit ( 2 ) 1 = enables the serial port and configures sckx, sdox, sdix and ssx as serial port pins 0 = disables the serial port and configures these pins as i/o port pins bit 4 ckp: clock polarity select bit 1 = idle state for clock is a high level 0 = idle state for clock is a low level bit 3-0 sspm<3:0>: master synchronous serial port mode select bits ( 3 ) 1010 = spi master mode, clock = f osc /(2 * ([sspxadd] + 1)) 0101 = spi slave mode, clock = sckx pin; ssx pin control is disabled, ssx can be used as an i/o pin 0100 = spi slave mode, clock = sckx pin; ssx pin control is enabled 0011 = spi master mode, clock = tmr2 output/2 0010 = spi master mode, clock = f osc /32 0001 = spi master mode, clock = f osc /8 0000 = spi master mode, clock = f osc /2 note 1: in master mode, the overflow bit is not set since each new reception (and transmission) is initiated by writing to the sspxbuf register. 2: when enabled, these pins must be properly configured as inputs or outputs. 3: bit combinations not specifically listed here are either reserved or implemented in i 2 c? mode only. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 166 ? 2013 microchip technology inc. register 14-4: sspxcon1: msspx control register 1 (i 2 c? mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wcol sspov sspen ( 1 ) ckp sspm3 ( 2 ) sspm2 ( 2 ) sspm1 ( 2 ) sspm0 ( 2 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 wcol: write collision detect bit in master transmit mode: 1 = a write to the sspxbuf register was attempted while the i 2 c conditions were not valid for a transmission to be started (must be cleared in software) 0 = no collision in slave transmit mode: 1 = the sspxbuf register is written while it is still transmitting the previous word (must be cleared in software) 0 = no collision in receive mode (master or slave modes): this is a dont care bit. bit 6 sspov: master synchronous serial port receive overflow indicator bit in receive mode: 1 = a byte is received while the sspxbuf register is still holding the previous byte (must be cleared in software) 0 = no overflow in transmit mode: this is a dont care bit in transmit mode. bit 5 sspen: master synchronous serial port enable bit ( 1 ) 1 = enables the serial port and configures the sdax and sclx pins as the serial port pins 0 = disables the serial port and configures these pins as i/o port pins bit 4 ckp: sclx release control bit in slave mode: 1 = releases clock 0 = holds clock low (clock stretch), used to ensure data setup time in master mode: unused in this mode. bit 3-0 sspm<3:0>: master synchronous serial port mode select bits ( 2 ) 1111 = i 2 c slave mode, 10-bit address with start and stop bit interrupts enabled 1110 = i 2 c slave mode, 7-bit address with start and stop bit interrupts enabled 1011 = i 2 c firmware controlled master mode (slave idle) 1000 = i 2 c master mode, clock = f osc /(2 * ([sspxadd] + 1)) ( 3 ) 0111 = i 2 c slave mode, 10-bit address 0110 = i 2 c slave mode, 7-bit address note 1: when enabled, the sdax and sclx pins must be configured as inputs. 2: bit combinations not specifically listed here are either reserved or implemented in spi mode only. 3: sspxadd values of 0, 1 or 2 are not supported when the baud rate generator is used with i 2 c mode. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 167 pic24fv16km204 family register 14-5: sspxcon2: m sspx control register 2 (i 2 c? mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 gcen ackstat ackdt ( 1 ) acken ( 2 ) rcen ( 2 ) pen ( 2 ) rsen ( 2 ) sen ( 2 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 gcen: general call enable bit (slave mode only) 1 = enables interrupt when a general call address (0000h) is received in the sspxsr 0 = general call address is disabled bit 6 ackstat: acknowledge status bit (master transmit mode only) 1 = acknowledge was not received from slave 0 = acknowledge was received from slave bit 5 ackdt: acknowledge data bit (master receive mode only) ( 1 ) 1 = no acknowledge 0 = acknowledge bit 4 acken: acknowledge sequence enable bit (master mode only) ( 2 ) 1 = initiates acknowledge sequence on sdax and sclx pins and transmits ackdt data bit; automatically cleared by hardware 0 = acknowledge sequence is idle bit 3 rcen: receive enable bit (master receive mode only) ( 2 ) 1 = enables receive mode for i 2 c 0 = receive is idle bit 2 pen: stop condition enable bit (master mode only) ( 2 ) 1 = initiates stop condition on sdax and sclx pins; automatically cleared by hardware 0 = stop condition is idle bit 1 rsen: repeated start condition enable bit (master mode only) ( 2 ) 1 = initiates repeated start condition on sdax and sclx pins; automatically cleared by hardware 0 = repeated start condition is idle bit 0 sen: start condition enable bit ( 2 ) master mode: 1 = initiates start condition on sdax and sclx pins; automatically clear ed by hardware 0 = start condition is idle slave mode: 1 = clock stretching is enabled for both slave transmit and slave receive (stretch is enabled) 0 = clock stretching is disabled note 1: the value that will be transmitted when the user initiates an acknowledge sequence at the end of a receive. 2: if the i 2 c module is active, these bits may not be set (no spooling) and the sspxbuf may not be written (or writes to the sspxbuf are disabled). downloaded from: http:///
pic24fv16km204 family ds30003030b-page 168 ? 2013 microchip technology inc. register 14-6: sspxcon3: msspx co ntrol register 3 (spi mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 acktim pcie scie boen ( 1 ) sdaht sbcde ahen dhen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 acktim: acknowledge time status bit (i 2 c? mode only) unused in spi mode. bit 6 pcie : stop condition interrupt enable bit (i 2 c mode only) unused in spi mode. bit 5 scie : start condition interrupt enable bit (i 2 c mode only) unused in spi mode. bit 4 boen: buffer overwrite enable bit ( 1 ) in spi slave mode: 1 = sspxbuf updates every time that a new data byte is shifted in, ignoring the bf bit 0 = if a new byte is received with the bf bit of the sspxstat register already set, the sspov bit of the sspxcon1 register is set and the buffer is not updated bit 3 sdaht: sdax hold time selection bit (i 2 c mode only) unused in spi mode. bit 2 sbcde: slave mode bus collision detect enable bit (i 2 c slave mode only) unused in spi mode. bit 1 ahen: address hold enable bit (i 2 c slave mode only) unused in spi mode. bit 0 dhen: data hold enable bit (slave mode only) unused in spi mode. note 1: for daisy-chained spi operation: allows the user to ignore all but the last received byte. sspov is still set when a new byte is received and bf = 1 , but hardware continues to write the most recent byte to sspxbuf. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 169 pic24fv16km204 family register 14-7: sspxcon3: m sspx control register 3 (i 2 c? mode) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 acktim ( 1 ) pcie scie boen sdaht sbcde ahen dhen bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 acktim: acknowledge time status bit ( 1 ) 1 = indicates the i 2 c bus is in an acknowledge sequence, set on the 8 th falling edge of the sclx clock 0 = not an acknowledge sequence, cleared on the 9 th rising edge of the sclx clock bit 6 pcie : stop condition interrupt enable bit 1 = enables interrupt on detection of a stop condition 0 = stop detection interrupts are disabled ( 2 ) bit 5 scie : start condition interrupt enable bit 1 = enables interrupt on detection of a start or restart condition 0 = start detection interrupts are disabled ( 2 ) bit 4 boen: buffer overwrite enable bit i 2 c master mode: this bit is ignored. i 2 c slave mode: 1 = sspxbuf is updated and an ack is generated for a received address/data byte, ignoring the state of the sspov bit only if the bf bit = 0 0 = sspxbuf is only updated when sspov is clear bit 3 sdaht: sdax hold time selection bit 1 = minimum of 300 ns hold time on sdax after the falling edge of sclx 0 = minimum of 100 ns hold time on sdax after the falling edge of sclx bit 2 sbcde: slave mode bus collision detect enable bit (slave mode only) 1 = enables slave bus collision interrupts 0 = slave bus collision interrupts are disabled bit 1 ahen: address hold enable bit (slave mode only) 1 = following the 8th falling edge of sclx for a matching received address byte; ckp bit of the sspxcon1 register will be cleared and sclx will be held low 0 = address holding is disabled bit 0 dhen: data hold enable bit (slave mode only) 1 = following the 8th falling edge of sclx for a received data byte; slave hardware clears the ckp bit of the sspxcon1 register and sclx is held low 0 = data holding is disabled note 1: this bit has no effect in slave modes for which start and stop condition detection is explicitly listed as enabled. 2: the acktim status bit is active only wh en the ahen bit or dhen bit is set. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 170 ? 2013 microchip technology inc. register 14-8: sspxadd: msspx slave address/baud rate generator register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 add7 add6 add5 add4 add3 add2 add1 add0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7-0 add<7:0>: slave address/baud rate generator value bits spi master and i 2 c? master modes: reload value for the baud rate generator. clock period is (([spxadd] + 1) * 2)/f osc . i 2 c slave modes: represents 7 or 8 bits of the slave address, depending on the addressing mode used: 7-bit mode: address is add<7:1>; add<0> is ignored. 10-bit lsb mode: add<7:0> are the least significant bits of the address. 10-bit msb mode: add<2:1> are the two most significant bits of the address; add<7:3> are always 11110 as a specification requirement; add<0> is ignored. register 14-9: sspxmsk: i 2 c? slave address mask register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 r/w-1 msk7 msk6 msk5 msk4 msk3 msk2 msk1 msk0 ( 1 ) bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7-0 msk<7:0>: slave address mask select bits ( 1 ) 1 = masking of corresponding bit of sspxadd is enabled 0 = masking of corresponding bit of sspxadd is disabled note 1: msk0 is not used as a mask bit in 7-bit addressing. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 171 pic24fv16km204 family register 14-10: padcfg1: pad co nfiguration control register u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 s d o 2 d i s ( 1 ) sck2dis ( 1 ) sdo1dis sck1dis bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-12 unimplemented: read as 0 bit 11 sdo2dis: mssp2 sdo2 pin disable bit ( 1 ) 1 = the spi output data (sdo2) of mssp2 to the pin is disabled 0 = the spi output data (sdo2) of mssp2 is output to the pin bit 10 sck2dis: mssp2 sck2 pin disable bit ( 1 ) 1 = the spi clock (sck2) of mssp2 to the pin is disabled 0 = the spi clock (sck2) of mssp2 is output to the pin bit 9 sdo1dis: mssp1 sdo1 pin disable bit 1 = the spi output data (sdo1) of mssp1 to the pin is disabled 0 = the spi output data (sdo1) of mssp1 is output to the pin bit 8 sck1dis: mssp1 sck1 pin disable bit 1 = the spi clock (sck1) of mssp1 to the pin is disabled 0 = the spi clock (sck1) of mssp1 is output to the pin bit 7-0 unimplemented: read as 0 note 1: these bits are implemented only on pic24fxxkm20x devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 172 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 173 pic24fv16km204 family 15.0 universal asynchronous receiver transmitter (uart) the universal asynchronous receiver transmitter (uart) module is one of the serial i/o modules available in this pic24f device family. the uart is a full-duplex, asynchronous system that can communicate with peripheral devices, such as personal computers, lin/j2602, rs-232 and rs-485 interfaces. this module also supports a hardware flow control option with the uxcts and uxrts pins, and also includes an irda ? encoder and decoder. the primary features of the uart module are: full-duplex, 8-bit or 9-bit data transmission through the uxtx and uxrx pins even, odd or no parity options (for 8-bit data) one or two stop bits hardware flow control option with uxcts and uxrts pins fully integrated baud rate generator (ibrg) with 16-bit prescaler baud rates ranging from 1 mbps to 15 bps at 16 mips 4-deep, first-in-first-out (fifo) transmit data buffer 4-deep fifo receive data buffer parity, framing and buffer overrun error detection support for 9-bit mode with address detect (9 th bit = 1 ) transmit and receive interrupts loopback mode for diagnostic support support for sync and break characters supports automatic baud rate detection irda ? encoder and decoder logic 16x baud clock output for irda support a simplified block diagram of the uartx module is shown in figure 15-1 . the uartx module consists of these important hardware elements: baud rate generator asynchronous transmitter asynchronous receiver figure 15-1: uartx module simplified block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the univer- sal asynchronous receiver transmitter, refer to the pic24f family reference manual , uart (ds39708). note: throughout this section, references to register and bit names that may be asso- ciated with a specific usart module are referred to generically by the use of x in place of the specific module number. thus, uxsta might refer to the usart status register for either usart1 or usart2. uxrx irda ? hardware flow control uartx receiver uartx transmitter uxtx uxcts uxrts uxbclk baud rate generator downloaded from: http:///
pic24fv16km204 family ds30003030b-page 174 ? 2013 microchip technology inc. 15.1 uartx baud rate generator (brg) the uartx module includes a dedicated 16-bit baud rate generator (brg). the uxbrg register controls the period of a free-running, 16-bit timer. equation 15-1 provides the formula for computation of the baud rate with brgh = 0 . equation 15-1: uartx baud rate with brgh = 0 ( 1 ) example 15-1 provides the calculation of the baud rate error for the following conditions: f cy = 4 mhz desired baud rate = 9600 the maximum baud rate (brgh = 0 ) possible is f cy /16 (for uxbrg = 0 ) and the minimum baud rate possible is f cy /(16 * 65536). equation 15-2 shows the formula for computation of the baud rate with brgh = 1 . equation 15-2: uartx baud rate with brgh = 1 ( 1 ) the maximum baud rate (brgh = 1 ) possible is f cy /4 (for uxbrg = 0 ) and the minimum baud rate possible is f cy /(4 * 65536). writing a new value to the uxbrg register causes the brg timer to be reset (cleared). this ensures the brg does not wait for a timer overflow before generating the new baud rate. example 15-1: baud rate erro r calculation (brgh = 0 ) ( 1 ) note 1: based on f cy = f osc /2; doze mode and pll are disabled. baud rate = f cy 16 (uxbrg + 1) f cy 16 baud rate uxbrg = ? 1 baud rate = f cy 4 (uxbrg + 1) f cy 4 baud rate uxbrg = ? 1 note 1: based on f cy = f osc /2; doze mode and pll are disabled. desired baud rate = f cy /(16 (uxbrg + 1)) solving for uxbrg value: uxbrg = ((f cy /desired baud rate)/16) ? 1 uxbrg = ((4000000/9600)/16) ? 1 uxbrg = 25 calculated baud rate = 4000000/(16 (25 + 1)) = 9615 error = (calculated baud rate ? desired baud rate) desired baud rate = (9615 ? 9600)/9600 =0.16% note 1: based on f cy = f osc /2; doze mode and pll are disabled. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 175 pic24fv16km204 family 15.2 transmitting in 8-bit data mode 1. set up the uartx: a) write the appropriate values for data, parity and stop bits. b) write the appropriate baud rate value to the uxbrg register. c) set up transmit and receive interrupt enable and priority bits. 2. enable the uartx. 3. set the utxen bit (causes a transmit interrupt, two cycles after being set). 4. write the data byte to the lower byte of the uxtxreg word. the value will be immediately transferred to the transmit shift register (tsr) and the serial bit stream will start shifting out with the next rising edge of the baud clock. 5. alternately, the data byte may be transferred while utxen = 0 , and then, the user may set utxen. this will cause the serial bit stream to begin immediately, because the baud clock will start from a cleared state. 6. a transmit interrupt will be generated as per interrupt control bit, utxiselx. 15.3 transmitting in 9-bit data mode 1. set up the uartx (as described in section 15.2 transmitting in 8-bit data mode ). 2. enable the uartx. 3. set the utxen bit (causes a transmit interrupt, two cycles after being set). 4. write uxtxreg as a 16-bit value only. 5. a word write to uxtxreg triggers the transfer of the 9-bit data to the tsr. the serial bit stream will start shifting out with the first rising edge of the baud clock. 6. a transmit interrupt will be generated as per the setting of control bit, utxiselx. 15.4 break and sync transmit sequence the following sequence will send a message frame header, made up of a break, followed by an auto-baud sync byte. 1. configure the uartx for the desired mode. 2. set utxen and utxbrk C this sets up the break character. 3. load the uxtxreg with a dummy character to initiate transmission (value is ignored). 4. write 55h to uxtxreg C loads the sync character into the transmit fifo. 5. after the break has been sent, the utxbrk bit is reset by hardware. the sync character now transmits. 15.5 receiving in 8-bit or 9-bit data mode 1. set up the uartx (as described in section 15.2 transmitting in 8-bit data mode ). 2. enable the uartx. 3. a receive interrupt will be generated when one or more data characters have been received, as per interrupt control bit, urxiselx. 4. read the oerr bit to determine if an overrun error has occurred. the oerr bit must be reset in software. 5. read uxrxreg. the act of reading the uxrxreg character will move the next character to the top of the receive fifo, including a new set of perr and ferr values. 15.6 operation of uxcts and uxrts control pins uartx clear-to-send (uxcts ) and request-to-send (uxrts ) are the two hardware controlled pins that are associated with the uartx module. these two pins allow the uartx to operate in simplex and flow con- trol modes. they are implemented to control the transmission and reception between the data terminal equipment (dte). the uen<1:0> bits in the uxmode register configure these pins. 15.7 infrared support the uartx module provides two types of infrared uartx support: one is the irda clock output to support an external irda encoder and decoder device (legacy module support), and the other is the full implementation of the irda encoder and decoder. as the irda modes require a 16x baud clock, they will only work when the brgh bit (uxmode<3>) is 0 . 15.7.1 external irda support C irda clock output to support external irda encoder and decoder devices, the uxbclk pin (same as the uxrts pin) can be configured to generate the 16x baud clock. when uen<1:0> = 11 , the uxbclk pin will output the 16x baud clock if the uartx module is enabled; it can be used to support the irda codec chip. 15.7.2 built-in irda encoder and decoder the uartx has full implementation of the irda encoder and decoder as part of the uartx module. the built-in irda encoder and decoder functionality is enabled using the iren bit (uxmode<12>). when enabled (iren = 1 ), the receive pin (uxrx) acts as the input from the infrared receiver. the transmit pin (uxtx) acts as the output to the infrared transmitter. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 176 ? 2013 microchip technology inc. register 15-1: uxmode: uartx mode register r/w-0 u-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 ( 2 ) r/w-0 ( 2 ) uarten usidl iren ( 1 ) rtsmd uen1 uen0 bit 15 bit 8 r/c-0, hc r/w-0 r/w-0, hc r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 wake lpback abaud urxinv brgh pdsel1 pdsel0 stsel bit 7 bit 0 legend: c = clearable bit hc = hardware clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 uarten: uartx enable bit 1 = uartx is enabled; all uartx pins are controlled by uartx, as defined by uen<1:0> 0 = uartx is disabled; all uartx pins are controlled by port latches, uartx power consumption is minimal bit 14 unimplemented: read as 0 bit 13 usidl: uartx stop in idle mode bit 1 = discontinues module operation when the device enters idle mode 0 = continues module operation in idle mode bit 12 iren: irda ? encoder and decoder enable bit ( 1 ) 1 = irda encoder and decoder are enabled 0 = irda encoder and decoder are disabled bit 11 rtsmd: mode selection for uxrts pin bit 1 =uxrts pin is in simplex mode 0 =uxrts pin is in flow control mode bit 10 unimplemented: read as 0 bit 9-8 uen<1:0>: uartx enable bits ( 2 ) 11 = uxtx, uxrx and uxbclk pins are enabled and used; uxcts pin is controlled by port latches 10 = uxtx, uxrx, uxcts and uxrts pins are enabled and used 01 = uxtx, uxrx and uxrts pins are enabled and used; uxcts pin is controlled by port latches 00 = uxtx and uxrx pins are enabled and used; uxcts and uxrts /uxbclk pins are controlled by port latches bit 7 wake: wake-up on start bit detect during sleep mode enable bit 1 = uartx will continue to sample the uxrx pin; interrupt is generated on the falling edge, bit is cleared in hardware on the following rising edge 0 = no wake-up is enabled bit 6 lpback: uartx loopback mode select bit 1 = enables loopback mode 0 = loopback mode is disabled bit 5 abaud: auto-baud enable bit 1 = enables baud rate measurement on the next character C requires reception of a sync field (55h); cleared in hardware upon completion 0 = baud rate measurement is disabled or completed bit 4 urxinv: uartx receive polarity inversion bit 1 = uxrx idle state is 0 0 = uxrx idle state is 1 note 1: this feature is is only available for the 16x brg mode (brgh = 0 ). 2: the bit availability depends on the pin availability. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 177 pic24fv16km204 family bit 3 brgh: high baud rate enable bit 1 = brg generates 4 clocks per bit period (4x baud clock, high-speed mode) 0 = brg generates 16 clocks per bit period (16x baud clock, standard mode) bit 2-1 pdsel<1:0>: parity and data selection bits 11 = 9-bit data, no parity 10 = 8-bit data, odd parity 01 = 8-bit data, even parity 00 = 8-bit data, no parity bit 0 stsel: stop bit selection bit 1 = two stop bits 0 = one stop bit register 15-1: uxmode: uartx mode register (continued) note 1: this feature is is only available for the 16x brg mode (brgh = 0 ). 2: the bit availability depends on the pin availability. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 178 ? 2013 microchip technology inc. register 15-2: uxsta: uartx status and control register r/w-0 r/w-0 r/w-0 u-0 r/w-0, hc r/w-0 r-0, hsc r-1, hsc utxisel1 utxinv utxisel0 utxbrk utxen utxbf trmt bit 15 bit 8 r/w-0 r/w-0 r/w-0 r-1, hsc r-0, hsc r-0, hsc r/c-0, hs r-0, hsc urxisel1 urxisel0 adden ridle perr ferr oerr urxda bit 7 bit 0 legend: hc = hardware clearable bit hs = hardware settable bit c = clearable bit hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15,13 utxisel<1:0>: uartx transmission interrupt mode selection bits 11 = reserved; do not use 10 = interrupt when a character is transferred to the transmit shift register (tsr) and as a result, the transmit buffer becomes empty 01 = interrupt when the last character is shifted out of the transmit shift register; all transmit operations are completed 00 = interrupt when a character is transferred to the transmit shift register (this implies there is at least one character open in the transmit buffer) bit 14 utxinv: irda ? encoder transmit polarity inversion bit if iren = 0 : 1 = uxtx idle 0 0 = uxtx idle 1 if iren = 1 : 1 = uxtx idle 1 0 = uxtx idle 0 bit 12 unimplemented: read as 0 bit 11 utxbrk: uartx transmit break bit 1 = sends sync break on next transmission C start bit, followed by twelve 0 bits, followed by stop bit; cleared by hardware upon completion 0 = sync break transmission is disabled or completed bit 10 utxen: uartx transmit enable bit 1 = transmit is enabled; uxtx pin is controlled by uartx 0 = transmit is disabled; any pending transmission is aborted and the buffer is reset; uxtx pin is controlled by the port register bit 9 utxbf: uartx transmit buffer full status bit (read-only) 1 = transmit buffer is full 0 = transmit buffer is not full, at least one more character can be written bit 8 trmt: transmit shift register empty bit (read-only) 1 = transmit shift register is empty and the transmit buffer is empty (the last transmission has completed) 0 = transmit shift register is not empty; a transmission is in progress or queued bit 7-6 urxisel<1:0>: uartx receive interrupt mode selection bits 11 = interrupt is set on an rsr transfer, making the receive buffer full (i.e., has 4 data characters) 10 = interrupt is set on an rsr transfer, making the receive buffer 3/4 full (i.e., has 3 data charac ters) 0x = interrupt is set when any character is received and transferred from the rsr to the receive buffer; receive buffer has one or more characters downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 179 pic24fv16km204 family bit 5 adden: address character detect bit (bit 8 of received data = 1 ) 1 = address detect mode is enabled; if 9-bit mode is not selected, this does not take effect 0 = address detect mode is disabled bit 4 ridle: receiver idle bit (read-only) 1 = receiver is idle 0 = receiver is active bit 3 perr: parity error status bit (read-only) 1 = parity error has been detected for the current character (character at t he top of the receive fifo) 0 = parity error has not been detected bit 2 ferr: framing error status bit (read-only) 1 = framing error has been detected for the current character (character at the top of the receive fifo) 0 = framing error has not been detected bit 1 oerr: receive buffer overrun error status bit (clear/read-only) 1 = receive buffer has overflowed 0 = receive buffer has not overflowed (clearing a previously set oerr bit ( 1 ? 0 transition) will reset the receiver buffer and the rsr to the empty state) bit 0 urxda: uartx receive buffer data available bit (read-only) 1 = receive buffer has data; at least one more characters can be read 0 = receive buffer is empty register 15-2: uxsta: uartx status and control register (continued) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 180 ? 2013 microchip technology inc. register 15-3: uxtxreg: uartx transmit register u-x u-x u-x u-x u-x u-x u-x w-x u t x 8 bit 15 bit 8 w-x w-x w-x w-x w-x w-x w-x w-x utx7 utx6 utx5 utx4 utx3 utx2 utx1 utx0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-9 unimplemented: read as 0 bit 8 utx8: data of the transmitted character bit (in 9-bit mode) bit 7-0 utx<7:0>: data of the transmitted character bits register 15-4: uxrxreg: uartx receive register u-0 u-0 u-0 u-0 u-0 u-0 u-0 r-0, hsc u r x 8 bit 15 bit 8 r-0, hsc r-0, hsc r-0, hsc r-0, hsc r-0, hsc r-0, hsc r-0, hsc r-0, hsc urx7 urx6 urx5 urx4 urx3 urx2 urx1 urx0 bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-9 unimplemented: read as 0 bit 8 urx8: data of the received character bit (in 9-bit mode) bit 7-0 urx<7:0>: data of the received character bits downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 181 pic24fv16km204 family 16.0 real-time clock and calendar (rtcc) the rtcc provides the user with a real-time clock and calendar (rtcc) function that can be calibrated. key features of the rtcc module are: operates in sleep and retention sleep modes selectable clock source provides hours, minutes and seconds using 24-hour format visibility of one half second period provides calendar C weekday, date, month and year alarm-configurable for half a second, one second, 10 seconds, one minute, 10 minutes, one hour, one day, one week, one month or one year alarm repeat with decrementing counter alarm with indefinite repeat chime year 2000 to 2099 leap year correction bcd format for smaller software overhead optimized for long term battery operation user calibration of the 32.768 khz clock crystal/32k intrc frequency with periodic auto-adjust optimized for long term battery operation fractional second synchronization calibration to within 2.64 seconds error per month calibrates up to 260 ppm of crystal error ability to periodically wake-up external devices without cpu intervention (external power control) power control output for external circuit control calibration takes effect every 15 seconds runs from any one of the following: - external real-time clock of 32.768 khz - internal 31.25 khz lprc clock - 50 hz or 60 hz external input 16.1 rtcc source clock the user can select between the sosc crystal oscillator, lprc internal oscillator or an external 50 hz/60 hz power line input as the clock reference for the rtcc module. this gives the user an option to trade off system cost, accuracy and power consumption, based on the overall system needs. figure 16-1: rtcc block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the real-time clock and calendar, refer to the pic24f family reference manual , real-time clock and calendar (rtcc) (ds39696). rtcc clock domain cpu clock domain rtcc rtcc prescalers rtcc timer comparator alarm registers with masks repeat counter 0.5 sec rtcc interrupt logic alrmval alcfgrpt rcfgcal alarm event year mthdy wkdyhr minsec almthdy alwdhr alminsec rtcc interrupt rtcout<1:0> rtcoe clock source 1s pin alarm pulse input from sosc/lprc oscillator or external source rtcval downloaded from: http:///
pic24fv16km204 family ds30003030b-page 182 ? 2013 microchip technology inc. 16.2 rtcc module registers the rtcc module registers are organized into three categories: rtcc control registers rtcc value registers alarm value registers 16.2.1 register mapping to limit the register interface, the rtcc timer and alarm time registers are accessed through corre- sponding register pointers. the rtcc value register window (rtcvalh and rtcvall) uses the rtcptrx bits (rcfgcal<9:8>) to select the desired timer register pair (see table 16-1 ). by writing the rtcvalh byte, the rtcc pointer value, the rtcptr<1:0> bits decrement by one until they reach 00 . once they reach 00 , the minutes and seconds value will be accessible through rtcvalh and rtcvall until the pointer value is manually changed. table 16-1: rtcval register mapping the alarm value register window (alrmvalh and alrmvall) uses the alrmptrx bits (alcfgrpt<9:8>) to select the desired alarm register pair (see table 16-2 ). by writing the alrmvalh byte, the alrmptr<1:0> bits (alarm pointer value) decrement by one until they reach 00 . once they reach 00 , the alrmmin and alrmsec value will be accessible through alrmvalh and alrmvall, until the pointer value is manually changed. table 16-2: alrmval register mapping considering that the 16-bit core does not distinguish between 8-bit and 16-bit read operations, the user must be aware that when reading either the alrmvalh or alrmvall bytes, the alrmptr<1:0> value will be decremented. the same applies to the rtcvalh or rtcvall bytes with the rtcptr<1:0> being decremented. 16.2.2 write lock in order to perform a write to any of the rtcc timer registers, the rtcwren bit (rcfgcal<13>) must be set (see example 16-1 and example 16-2 ). 16.2.3 selecting rtcc clock source there are four reference source clock options that can be selected for the rtcc using the rtcclk<1:0> bits (rtcpwc<11:10>): 00 = secondary oscillator, 01 = lprc, 10 = 50 hz external clock and 11 = 60 hz external clock. example 16-1: setting the rtcwren bit in assembly example 16-2: setting the rtcwren bit in c rtcptr<1:0> rtcc value register window rtcval<15:8> rtcval<7:0> 00 minutes seconds 01 weekday hours 10 month day 11 y e a r alrmptr <1:0> alarm value register window alrmvalh<15:8> alrmvall<7:0> 00 alrmmin alrmsec 01 alrmwd alrmhr 10 alrmmnth alrmday 11 pwcstab pwcsamp note: this only applies to read operations and not write operations. note: to avoid accidental writes to the timer, it is recommended that the rtcwren bit (rcfgcal<13>) is kept clear at any other time. for the rtcwren bit to be set, there is only one instruction cycle time window allowed between the 55h/aa sequence and the setting of rtcwren. therefore, it is recommended that code follow the procedure in example 16-2 . push w7 ; store w7 and w8 values on the stack. push w8 disi #5 ; disable interrupts until sequence is complete. mov #0x55, w7 ; write 0x55 unlock value to nvmkey. mov w7, nvmkey mov #0xaa, w8 ; write 0xaa unlock value to nvmkey. mov w8, nvmkey bset rcfgcal, #13 ; set the rtcwren bit. pop w8 ; restore the original w register values from the stack. pop w7 //this builtin function executes implements the unlock sequence and sets //the rtcwren bit. __builtin_write_rtcwen(); downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 183 pic24fv16km204 family 16.2.4 rtcc control registers register 16-1: rcfgcal: rtcc calibration and configuration register ( 1 ) r/w-0 u-0 r/w-0 r-0, hsc r-0, hsc r/w-0 r/w-0 r/w-0 rtcen ( 2 ) rtcwren rtcsync halfsec ( 3 ) rtcoe rtcptr1 rtcptr0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 cal7 cal6 cal5 cal4 cal3 cal2 cal1 cal0 bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 rtcen: rtcc enable bit ( 2 ) 1 = rtcc module is enabled 0 = rtcc module is disabled bit 14 unimplemented: read as 0 bit 13 rtcwren: rtcc value registers write enable bit 1 = rtcvalh and rtcvall registers can be written to by the user 0 = rtcvalh and rtcvall registers are locked out from being written to by the user bit 12 rtcsync: rtcc value registers read synchronization bit 1 = rtcvalh, rtcvall and alcfgrpt registers can change while reading due to a rollover ripple resulting in an invalid data read. if the register is read twice and results in the same data, the data can be assumed to be valid. 0 = rtcvalh, rtcvall or alcfgrpt registers can be read without concern over a rollover ripple bit 11 halfsec: half second status bit ( 3 ) 1 = second half period of a second 0 = first half period of a second bit 10 rtcoe: rtcc output enable bit 1 = rtcc output is enabled 0 = rtcc output is disabled bit 9-8 rtcptr<1:0>: rtcc value register window pointer bits points to the corresponding rtcc value registers when reading the rtcvalh and rtcvall registers. the rtcptr<1:0> value decrements on every read or write of rtcvalh until it reaches 00 . rtcval<15:8>: 00 = minutes 01 = weekday 10 = month 11 = reserved rtcval<7:0>: 00 = seconds 01 = hours 10 = day 11 = year note 1: the rcfgcal register is only affected by a por. 2: a write to the rtcen bit is only allowed when rtcwren = 1 . 3: this bit is read-only; it is cleared to 0 on a write to the lower half of the minsec register. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 184 ? 2013 microchip technology inc. bit 7-0 cal<7:0>: rtc drift calibration bits 01111111 = maximum positive adjustment; adds 508 rtc clock pulses every one minute .. . 00000001 = minimum positive adjustment; adds 4 rtc clock pulses every one minute 00000000 = no adjustment 11111111 = minimum negative adjustment; subtracts 4 rtc clock pulses every one minute .. . 10000000 = maximum negative adjustment; subtracts 512 rtc clock pulses every one minute register 16-1: rcfgcal: rtcc calibration and configuration register ( 1 ) (continued) note 1: the rcfgcal register is only affected by a por. 2: a write to the rtcen bit is only allowed when rtcwren = 1 . 3: this bit is read-only; it is cleared to 0 on a write to the lower half of the minsec register. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 185 pic24fv16km204 family register 16-2: rtcpwc: rtcc configuration register 2 ( 1 ) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 pwcen pwcpol pwccpre pwcspre rtcclk1 ( 2 ) rtcclk0 ( 2 ) rtcout1 rtcout0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 pwcen: power control enable bit 1 = power control is enabled 0 = power control is disabled bit 14 pwcpol: power control polarity bit 1 = power control output is active-high 0 = power control output is active-low bit 13 pwccpre: power control/stability prescaler bits 1 = pwc stability window clock is divide-by-2 of source rtcc clock 0 = pwc stability window clock is divide-by-1 of source rtcc clock bit 12 pwcspre: power control sample prescaler bits 1 = pwc sample window clock is divide-by-2 of source rtcc clock 0 = pwc sample window clock is divide-by-1 of source rtcc clock bit 11-10 rtcclk<1:0>: rtcc clock select bits ( 2 ) determines the source of the internal rtcc clock, which is used for all rtcc timer operations. 00 = external secondary oscillator (sosc) 01 = internal lprc oscillator 10 = external power line source C 50 hz 11 = external power line source C 60 hz bit 9-8 rtcout<1:0>: rtcc output select bits determines the source of the rtcc pin output. 00 = rtcc alarm pulse 01 = rtcc seconds clock 10 = rtcc clock 11 = power control bit 7-0 unimplemented: read as 0 note 1: the rtcpwc register is only affected by a por. 2: when a new value is written to these register bits, the seconds value register should also be written to properly reset the clock prescalers in the rtcc. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 186 ? 2013 microchip technology inc. register 16-3: alcfgrpt: al arm configuration register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 alrmen chime amask3 amask2 amask1 amask0 alrmptr1 alrmptr0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 arpt7 arpt6 arpt5 arpt4 arpt3 arpt2 arpt1 arpt0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 alrmen: alarm enable bit 1 = alarm is enabled (cleared automatically after an alarm event whenever arpt<7:0> = 00h and chime = 0 ) 0 = alarm is disabled bit 14 chime: chime enable bit 1 = chime is enabled; arpt<7:0> bits are allowed to roll over from 00h to ffh 0 = chime is disabled; arpt<7:0> bits stop once they reach 00h bit 13-10 amask<3:0>: alarm mask configuration bits 0000 = every half second 0001 = every second 0010 = every 10 seconds 0011 = every minute 0100 = every 10 minutes 0101 = every hour 0110 = once a day 0111 = once a week 1000 = once a month 1001 = once a year (except when configured for february 29 th , once every 4 years) 101x = reserved C do not use 11xx = reserved C do not use bit 9-8 alrmptr<1:0>: alarm value register window pointer bits points to the corresponding alarm value registers when reading the alrmvalh and alrmvall registers. the alrmptr<1:0> value decrements on every read or write of alrmvalh until it reaches 00 . alrmval<15:8>: 00 = alrmmin 01 = alrmwd 10 = alrmmnth 11 = unimplemented alrmval<7:0>: 00 = alrmsec 01 = alrmhr 10 = alrmday 11 = unimplemented bit 7-0 arpt<7:0>: alarm repeat counter value bits 11111111 = alarm will repeat 255 more times .. . 00000000 = alarm will not repeat the counter decrements on any alarm event; it is prevented from rolling over from 00h to ffh unless chime = 1 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 187 pic24fv16km204 family 16.2.5 rtcval register mappings register 16-4: year: year value register ( 1 ) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x yrten3 yrten2 yrten1 yrten0 yrone3 yrone2 yrone1 yrone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7-4 yrten<3:0>: binary coded decimal value of years tens digit bits contains a value from 0 to 9. bit 3-0 yrone<3:0>: binary coded decimal value of years ones digit bits contains a value from 0 to 9. note 1: a write to the year register is only allowed when rtcwren = 1 . register 16-5: mthdy: month and day value register ( 1 ) u-0 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x mthten0 mthone3 mthone2 mthone1 mthone0 bit 15 bit 8 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x dayten1 dayten0 dayone3 dayone2 dayone1 dayone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-13 unimplemented: read as 0 bit 12 mthten0: binary coded decimal value of months tens digit bit contains a value of 0 or 1 . bit 11-8 mthone<3:0>: binary coded decimal value of months ones digit bits contains a value from 0 to 9. bit 7-6 unimplemented: read as 0 bit 5-4 dayten<1:0>: binary coded decimal value of days tens digit bits contains a value from 0 to 3. bit 3-0 dayone<3:0>: binary coded decimal value of days ones digit bits contains a value from 0 to 9. note 1: a write to this register is only allowed when rtcwren = 1 . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 188 ? 2013 microchip technology inc. register 16-6: wkdyhr: weekday and hours value register ( 1 ) u-0 u-0 u-0 u-0 u-0 r/w-x r/w-x r/w-x wday2 wday1 wday0 bit 15 bit 8 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x hrten1 hrten0 hrone3 hrone2 hrone1 hrone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 wday<2:0>: binary coded decimal value of weekday digit bits contains a value from 0 to 6. bit 7-6 unimplemented: read as 0 bit 5-4 hrten<1:0>: binary coded decimal value of hours tens digit bits contains a value from 0 to 2. bit 3-0 hrone<3:0>: binary coded decimal value of hours ones digit bits contains a value from 0 to 9. note 1: a write to this register is only allowed when rtcwren = 1 . register 16-7: minsec: minutes and seconds value register u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x minten2 minten1 minten0 minone3 minone2 minone1 minone0 bit 15 bit 8 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x secten2 secten1 secten0 secone3 secone2 secone1 secone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 minten<2:0>: binary coded decimal value of minutes tens digit bits contains a value from 0 to 5. bit 11-8 minone<3:0>: binary coded decimal value of minutes ones digit bits contains a value from 0 to 9. bit 7 unimplemented: read as 0 bit 6-4 secten<2:0>: binary coded decimal value of seconds tens digit bits contains a value from 0 to 5. bit 3-0 secone<3:0>: binary coded decimal value of seconds ones digit bits contains a value from 0 to 9. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 189 pic24fv16km204 family 16.2.6 alrmval register mappings register 16-8: almthdy: alarm month and day value register ( 1 ) u-0 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x mthten0 mthone3 mthone2 mthone1 mthone0 bit 15 bit 8 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x dayten1 dayten0 dayone3 dayone2 dayone1 dayone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-13 unimplemented: read as 0 bit 12 mthten0: binary coded decimal value of months tens digit bit contains a value of 0 or 1 . bit 11-8 mthone<3:0>: binary coded decimal value of months ones digit bits contains a value from 0 to 9. bit 7-6 unimplemented: read as 0 bit 5-4 dayten<1:0>: binary coded decimal value of days tens digit bits contains a value from 0 to 3. bit 3-0 dayone<3:0>: binary coded decimal value of days ones digit bits contains a value from 0 to 9. note 1: a write to this register is only allowed when rtcwren = 1 . register 16-9: alwdhr: alarm weekday and hours value register ( 1 ) u-0 u-0 u-0 u-0 u-0 r/w-x r/w-x r/w-x wday2 wday1 wday0 bit 15 bit 8 u-0 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x hrten1 hrten0 hrone3 hrone2 hrone1 hrone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-11 unimplemented: read as 0 bit 10-8 wday<2:0>: binary coded decimal value of weekday digit bits contains a value from 0 to 6. bit 7-6 unimplemented: read as 0 bit 5-4 hrten<1:0>: binary coded decimal value of hours tens digit bits contains a value from 0 to 2. bit 3-0 hrone<3:0>: binary coded decimal value of hours ones digit bits contains a value from 0 to 9. note 1: a write to this register is only allowed when rtcwren = 1 . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 190 ? 2013 microchip technology inc. register 16-10: alminsec: alarm mi nutes and seconds value register u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x minten2 minten1 minten0 minone3 minone2 minone1 minone0 bit 15 bit 8 u-0 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x secten2 secten1 secten0 secone3 secone2 secone1 secone0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 minten<2:0>: binary coded decimal value of minutes tens digit bits contains a value from 0 to 5. bit 11-8 minone<3:0>: binary coded decimal value of minutes ones digit bits contains a value from 0 to 9. bit 7 unimplemented: read as 0 bit 6-4 secten<2:0>: binary coded decimal value of seconds tens digit bits contains a value from 0 to 5. bit 3-0 secone<3:0>: binary coded decimal value of seconds ones digit bits contains a value from 0 to 9. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 191 pic24fv16km204 family register 16-11: rtccswt: rtcc contro l/sample window timer register ( 1 ) r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x pwcstab7 pwcstab6 pwcstab5 pwcstab4 pwcstab3 pwcstab2 pwcstab1 pwcstab0 bit 15 bit 8 r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x r/w-x pwcsamp7 pwcsamp6 pwcsamp5 pwcsamp4 pwcsamp3 pwcsamp2 pwcsamp1 pwcsamp0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 pwcstab<7:0>: pwm stability window timer bits 11111111 = stability window is 255 t pwcclk clock periods .. . 00000000 = stability window is 0 t pwcclk clock periods the sample window starts when the alarm event triggers. the stability window timer starts counting from every alarm event when pwcen = 1 . bit 7-0 pwcsamp<7:0>: pwm sample window timer bits 11111111 = sample window is always enabled, even when pwcen = 0 11111110 = sample window is 254 t pwcclk clock periods .. . 00000000 = sample window is 0 t pwcclk clock periods the sample window timer starts counting at the end of the stability window when pwcen = 1 . if pwcstab<7:0> = 00000000 , the sample window timer starts counting from every alarm event when pwcen = 1 . note 1: a write to this register is only allowed when rtcwren = 1 . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 192 ? 2013 microchip technology inc. 16.3 calibration the real-time crystal input can be calibrated using the periodic auto-adjust feature. when properly calibrated, the rtcc can provide an error of less than 3 seconds per month. this is accomplished by finding the number of error clock pulses and storing the value into the lower half of the rcfgcal register. the 8-bit signed value, loaded into the lower half of rcfgcal, is multi- plied by four and will be either added or subtracted from the rtcc timer, once every minute. refer to the steps below for rtcc calibration: 1. using another timer resource on the device, the user must find the error of the 32.768 khz crystal. 2. once the error is known, it must be converted to the number of error clock pulses per minute. 3. a) if the oscillator is faster than ideal (negative result from step 2), the rcfgcal register value must be negative. this causes the specified number of clock pulses to be subtracted from the timer counter, once every minute. b) if the oscillator is slower than ideal (positive result from step 2), the rcfgcal register value must be positive. this causes the specified number of clock pulses to be subtracted from the timer counter, once every minute. equation 16-1: writes to the lower half of the rcfgcal register should only occur when the timer is turned off, or immediately after the rising edge of the seconds pulse, except when seconds = 00, 15, 30 or 45. this is due to the auto-adjust of the rtcc at 15 second intervals. 16.4 alarm configurable from half second to one year enabled using the alrmen bit (alcfgrpt<15>) one-time alarm and repeat alarm options are available 16.4.1 configuring the alarm the alarm feature is enabled using the alrmen bit. this bit is cleared when an alarm is issued. writes to alrmval should only take place when alrmen = 0 . as shown in figure 16-2 , the interval selection of the alarm is configured through the amaskx bits (alcfgrpt<13:10>). these bits determine which and how many digits of the alarm must match the clock value for the alarm to occur. the alarm can also be configured to repeat based on a preconfigured interval. the amount of times this occurs, once the alarm is enabled, is stored in the arpt<7:0> bits (alcfgrpt<7:0>). when the value of the arptx bits equals 00h and the chime bit (alcfgrpt<14>) is cleared, the repeat function is disabled, and only a single alarm will occur. the alarm can be repeated up to 255 times by loading arpt<7:0> with ffh. after each alarm is issued, the value of the arptx bits is decremented by one. once the value has reached 00h, the alarm will be issued one last time, after which, the alrmen bit will be cleared automatically and the alarm will turn off. indefinite repetition of the alarm can occur if the chime bit = 1 . instead of the alarm being disabled when the value of the arptx bits reaches 00h, it rolls over to ffh and continues counting indefinitely while chime is set. 16.4.2 alarm interrupt at every alarm event, an interrupt is generated. in addi- tion, an alarm pulse output is provided that operates at half the frequency of the alarm. this output is com- pletely synchronous to the rtcc clock and can be used as a trigger clock to other peripherals. (ideal frequency ? ? measured frequency) * 60 = clocks per minute ? ideal frequency = 32,768 hz note: it is up to the user to include, in the error value, the initial error of the crystal: drift due to temperature and drift due to crystal aging. note: changing any of the registers, other than the rcfgcal and alcfgrpt registers, and the chime bit while the alarm is enabled (alrmen = 1 ), can result in a false alarm event leading to a false alarm interrupt. to avoid a false alarm event, the timer and alarm values should only be changed while the alarm is disabled (alrmen = 0 ). it is recommended that the alcfgrpt register and chime bit be changed when rtcsync = 0 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 193 pic24fv16km204 family figure 16-2: alarm mask settings 16.5 power control the rtcc includes a power control feature that allows the device to periodically wake-up an external device, wait for the device to be stable before sampling wake-up events from that device and then shut down the external device. this can be done completely autonomously by the rtcc, without the need to wake from the current low-power mode (sleep, deep sleep, etc.). to enable this feature, the rtcc must be enabled (rtcen = 1 ), the pwcen register bit must be set and the rtcc pin must be driving the pwc control signal (rtcoe = 1 and rtcclk<1:0> = 11 ). the polarity of the pwc control signal may be chosen using the pwcpol register bit. active-low or active-high may be used with the appropriate external switch to turn on or off the power to one or more exter- nal devices. the active-low setting may also be used in conjunction with an open-drain setting on the rtcc pin. this setting is able to drive the gnd pin(s) of the external device directly (with the appropriate external v dd pull-up device), without the need for external switches. finally, the chime bit should be set to enable the pwc periodicity. note 1: annually, except when configured for february 29. s ss mss mm s s hh mm ss dh h m m s s dd hh mm s s mm d d h h mm s s day of the week month day hours minutes seconds alarm mask setting (amask<3:0>) 0000 - every half second 0001 - every second 0010 - every 10 seconds 0011 - every minute 0100 - every 10 minutes 0101 - every hour 0110 - every day 0111 - every week 1000 - every month 1001 - every year (1) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 194 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 195 pic24fv16km204 family 17.0 configurable logic cell (clc) the configurable logic cell (clc) module allows the user to specify combinations of signals as inputs to a logic function and to use the logic output to control other peripherals or i/o pins. this provides greater flex- ibility and potential in embedded designs since the clc module can operate outside the limitations of software execution and supports a vast amount of output designs. there are four input gates to the selected logic func- tion. these four input gates select from a pool of up to 32 signals that are selected using four data source selection multiplexers. figure 17-1 shows an overview of the module. figure 17-3 shows the details of the data source multiplexers and logic input gate connections. figure 17-1: clcx module gate 1 gate 2 gate 3 gate 4 interrupt det logic function input data selection gates clcx lcoe logic lcpol lcout dqle clcfrz mode<2:0> clcx clcin[0] clcin[1] clcin[2] clcin[3] clcin[4] clcin[5] clcin[6] clcin[7] clcin[8] clcin[9] clcin[10] clcin[11] clcin[12] clcin[13] clcin[14] clcin[15] trisx control interrupt det intp intn lcen clcxif sets flag note: all register bits shown in this figure can be found in the clcxconl register. output output clcin[16] clcin[17] clcin[18] clcin[19] clcin[20] clcin[21] clcin[22] clcin[23] clcin[24] clcin[25] clcin[26] clcin[27] clcin[28] clcin[29] clcin[30] clcin[31] see figure 17-2 see figure 17-3 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 196 ? 2013 microchip technology inc. figure 17-2: clcx logic func tion combinatorial options gate 1 gate 2 gate 3 gate 4 logic output gate 1 gate 2 gate 3 gate 4 logic output gate 1 gate 2 gate 3 gate 4 logic output sr q gate 1 gate 2 gate 3 gate 4 logic output dq gate 1 gate 2 gate 3 gate 4 logic output s r jq gate 2 gate 3 gate 4 logic output r gate 1 k dq gate 1 gate 2 gate 3 gate 4 logic output s r dq gate 1 gate 3 logic output r gate 4 gate 2 mode<2:0> = 000 mode<2:0> = 010 mode<2:0> = 001 mode<2:0> = 011 mode<2:0> = 100 mode<2:0> = 110 mode<2:0> = 101 mode<2:0> = 111 le and C or or C xor 4-input and s-r latch 1-input d flip-flop with s and r 2-input d flip-flop with r 1-input transparent latch with s and r j-k flip-flop with r downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 197 pic24fv16km204 family figure 17-3: clcx input source selection diagram gate 1 g1pol data gate 1 g1d1t gate 2 gate 3 gate 4 data gate 2 data gate 3 data gate 4 g1d1n ds1x (clcxsel<2:0>) ds2x (clcxsel<6:4>) clcin[0] clcin[1] clcin[2] clcin[5] clcin[6] clcin[7] data selection note: all controls are undefined at power-up. data 1 non-inverted data 1 data 2 non-inverted data 2 data 3 non-inverted data 3 data 4 non-inverted data 4 (same as data gate 1) (same as data gate 1) (same as data gate 1) g1d2t g1d2n g1d3t g1d3n g1d4t g1d4n inverted inverted inverted inverted clcin[8] clcin[9] clcin[10] clcin[13] clcin[14] clcin[15] clcin[3] clcin[4] clcin[11] clcin[12] clcin[18] clcin[21] clcin[22] clcin[23] clcin[19] clcin[20] clcin[17] clcin[16] ds3x (clcxsel<10:8>) clcin[26] clcin[29] clcin[30] clcin[31] clcin[27] clcin[28] clcin[25] clcin[24] ds4x (clcxsel<14:12>) 000111 000111 000111 000111 (clcxconh<0>) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 198 ? 2013 microchip technology inc. 17.1 control registers the clcx module is controlled by the following registers: clcxconl clcxconh clcxsel clcxglsl clcxglsh the clcx control registers (clcxconl and clcxconh) are used to enable the module and inter- rupts, control the output enable bit, select output polarity and select the logic function. the clcx control registers also allow the user to control the logic polarity of not only the cell output, but also some intermediate variables. the clcx source select register (clcxsel) allows the user to select up to 4 data input sources using the 4 data input selection multiplexers. each multiplexer has a list of 8 data sources available. the clcx gate logic select registers (clcxglsl and clcxglsh) allow the user to select which outputs from each of the selection muxes are used as inputs to the input gates of the logic cell. each data source mux outputs both a true and a negated version of its output. all of these 8 signals are enabled, ored together by the logic cell input gates. register 17-1: clcxconl: clcx control register (low) r/w-0 u-0 u-0 u-0 r/w-0 r/w-0 u-0 u-0 lcen intp intn bit 15 bit 8 r-0 r-0 r/w-0 u-0 u-0 r/w-0 r/w-0 r/w-0 lcoe lcout lcpol mode2 mode1 mode0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 lcen: clcx enable bit 1 = clcx is enabled and mixing input signals 0 = clcx is disabled and has logic zero outputs bit 14-12 unimplemented: read as 0 bit 11 intp: clcx positive edge interrupt enable bit 1 = interrupt will be generated when a rising edge occurs on lcout 0 = interrupt will not be generated bit 10 intn: clcx negative edge interrupt enable bit 1 = interrupt will be generated when a falling edge occurs on lcout 0 = interrupt will not be generated bit 9-8 unimplemented: read as 0 bit 7 lcoe: clcx port enable bit 1 = clcx port pin output is enabled 0 = clcx port pin output is disabled bit 6 lcout: clcx data output status bit 1 = clcx output high 0 = clcx output low bit 5 lcpol: clcx output polarity control bit 1 = the output of the module is inverted 0 = the output of the module is not inverted bit 4-3 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 199 pic24fv16km204 family bit 2-0 mode<2:0>: clcx mode bits 111 = cell is a 1-input transparent latch with s and r 110 = cell is a jk flip-flop with r 101 = cell is a 2-input d flip-flop with r 100 = cell is a 1-input d flip-flop with s and r 011 = cell is an sr latch 010 = cell is a 4-input and 001 = cell is an or-xor 000 = cell is a and-or register 17-1: clcxconl : clcx control register (low) (continued) register 17-2: clcxconh: clcx control register (high) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 g4pol g3pol g2pol g1pol bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-4 unimplemented: read as 0 bit 3 g4pol: gate 4 polarity control bit 1 = the output of channel 4 logic is inverted when applied to the logic cell 0 = the output of channel 4 logic is not inverted bit 2 g3pol: gate 3 polarity control bit 1 = the output of channel 3 logic is inverted when applied to the logic cell 0 = the output of channel 3 logic is not inverted bit 1 g2pol: gate 2 polarity control bit 1 = the output of channel 2 logic is inverted when applied to the logic cell 0 = the output of channel 2 logic is not inverted bit 0 g1pol: gate 1 polarity control bit 1 = the output of channel 1 logic is inverted when applied to the logic cell 0 = the output of channel 1 logic is not inverted downloaded from: http:///
pic24fv16km204 family ds30003030b-page 200 ? 2013 microchip technology inc. register 17-3: clcxsel: clcx input mux select register u-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 ds42 ds41 ds40 ds32 ds31 ds30 bit 15 bit 8 u-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 ds22 ds21 ds20 ds12 ds11 ds10 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-12 ds4<2:0>: data selection mux 4 signal selection bits 111 = mccp3 compare event flag (ccp3if) 110 = mccp1 compare event flag (ccp1if) 101 = digital logic low 100 = ctmu trigger interrupt for clc1: 011 = spi1 sdix 010 = comparator 3 output 001 = clc2 output 000 = clcinb i/o pin for clc2: 011 = spi2 sdix 010 = comparator 3 output 001 = clc1 output 000 = clcinb i/o pin bit 11 unimplemented: read as 0 bit 10-8 ds3<2:0>: data selection mux 3 signal selection bits 111 = mccp3 compare event flag (ccp3if) 110 = mccp2 compare event flag (ccp2if) 101 = digital logic low for clc1: 100 = uart1 rx 011 = spi1 sdox 010 = comparator 2 output 001 = clc1 output 000 = clcina i/o pin for clc2: 100 = uart2 rx 011 = spi2 sdox 010 = comparator 2 output 001 = clc2 output 000 = clcina i/o pin bit 7 unimplemented: read as 0 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 201 pic24fv16km204 family bit 6-4 ds2<2:0>: data selection mux 2 signal selection bits 111 = mccp2 compare event flag (ccp2if) 110 = mccp1 compare event flag (ccp1if) 101 = digital logic low 100 = a/d end of conversion event for clc1: 011 = uart1 tx 010 = comparator 1 output 001 = clc2 output 000 = clcinb i/o pin for clc2: 011 = uart2 tx 010 = comparator 1 output 001 = clc1 output 000 = clcinb i/o pin bit 3 unimplemented: read as 0 bit 2-0 ds1<2:0>: data selection mux 1 signal selection bits 111 = sccp5 compare event flag (ccp5if) 110 = sccp4 compare event flag (ccp4if) 101 = digital logic low 100 = 8 mhz frc clock source 011 = lprc clock source 010 = sosc clock source 001 = system clock (t cy ) 000 = clcina i/o pin register 17-3: clcxsel: clcx input mux select register (continued) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 202 ? 2013 microchip technology inc. register 17-4: clcxglsl: clcx gate logic input select low register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 g2d4t g2d4n g2d3t g2d3n g2d2t g2d2n g2d1t g2d1n bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 g1d4t g1d4n g1d3t g1d3n g1d2t g1d2n g1d1t g1d1n bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 g2d4t: gate 2 data source 4 true enable bit 1 = the data source 4 inverted signal is enabled for gate 2 0 = the data source 4 inverted signal is disabled for gate 2 bit 14 g2d4n: gate 2 data source 4 negated enable bit 1 = the data source 4 inverted signal is enabled for gate 2 0 = the data source 4 inverted signal is disabled for gate 2 bit 13 g2d3t: gate 2 data source 3 true enable bit 1 = the data source 3 inverted signal is enabled for gate 2 0 = the data source 3 inverted signal is disabled for gate 2 bit 12 g2d3n: gate 2 data source 3 negated enable bit 1 = the data source 3 inverted signal is enabled for gate 2 0 = the data source 3 inverted signal is disabled for gate 2 bit 11 g2d2t: gate 2 data source 2 true enable bit 1 = the data source 2 inverted signal is enabled for gate 2 0 = the data source 2 inverted signal is disabled for gate 2 bit 10 g2d2n: gate 2 data source 2 negated enable bit 1 = the data source 2 inverted signal is enabled for gate 2 0 = the data source 2 inverted signal is disabled for gate 2 bit 9 g2d1t: gate 2 data source 1 true enable bit 1 = the data source 1 inverted signal is enabled for gate 2 0 = the data source 1 inverted signal is disabled for gate 2 bit 8 g2d1n: gate 2 data source 1 negated enable bit 1 = the data source 2 inverted signal is enabled for gate 1 0 = the data source 2 inverted signal is disabled for gate 1 bit 7 g1d4t: gate 1 data source 4 true enable bit 1 = the data source 4 inverted signal is enabled for gate 1 0 = the data source 4 inverted signal is disabled for gate 1 bit 6 g1d4n: gate 1 data source 4 negated enable bit 1 = the data source 4 inverted signal is enabled for gate 1 0 = the data source 4 inverted signal is disabled for gate 1 bit 5 g1d3t: gate 1 data source 3 true enable bit 1 = the data source 3 inverted signal is enabled for gate 1 0 = the data source 3 inverted signal is disabled for gate 1 bit 4 g1d3n: gate 1 data source 3 negated enable bit 1 = the data source 3 inverted signal is enabled for gate 1 0 = the data source 3 inverted signal is disabled for gate 1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 203 pic24fv16km204 family bit 3 g1d2t: gate 1 data source 2 true enable bit 1 = the data source 2 inverted signal is enabled for gate 1 0 = the data source 2 inverted signal is disabled for gate 1 bit 2 g1d2n: gate 1 data source 2 negated enable bit 1 = the data source 2 inverted signal is enabled for gate 1 0 = the data source 2 inverted signal is disabled for gate 1 bit 1 g1d1t: gate 1 data source 1 true enable bit 1 = the data source 1 inverted signal is enabled for gate 1 0 = the data source 1 inverted signal is disabled for gate 1 bit 0 g1d1n: gate 1 data source 1 negated enable bit 1 = the data source 1 inverted signal is enabled for gate 1 0 = the data source 1 inverted signal is disabled for gate 1 register 17-4: clcxglsl: clcx gate logic input select low register (continued) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 204 ? 2013 microchip technology inc. register 17-5: clcxglsh: clcx gate logic input select high register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 g4d4t g4d4n g4d3t g4d3n g4d2t g4d2n g4d1t g4d1n bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 g3d4t g3d4n g3d3t g3d3n g3d2t g3d2n g3d1t g3d1n bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 g4d4t: gate 4 data source 4 true enable bit 1 = the data source 4 inverted signal is enabled for gate 4 0 = the data source 4 inverted signal is disabled for gate 4 bit 14 g4d4n: gate 4 data source 4 negated enable bit 1 = the data source 4 inverted signal is enabled for gate 4 0 = the data source 4 inverted signal is disabled for gate 4 bit 13 g4d3t: gate 4 data source 3 true enable bit 1 = the data source 3 inverted signal is enabled for gate 4 0 = the data source 3 inverted signal is disabled for gate 4 bit 12 g4d3n: gate 4 data source 3 negated enable bit 1 = the data source 3 inverted signal is enabled for gate 4 0 = the data source 3 inverted signal is disabled for gate 4 bit 11 g4d2t: gate 4 data source 2 true enable bit 1 = the data source 2 inverted signal is enabled for gate 4 0 = the data source 2 inverted signal is disabled for gate 4 bit 10 g4d2n: gate 4 data source 2 negated enable bit 1 = the data source 2 inverted signal is enabled for gate 4 0 = the data source 2 inverted signal is disabled for gate 4 bit 9 g4d1t: gate 4 data source 1 true enable bit 1 = the data source 1 inverted signal is enabled for gate 4 0 = the data source 1 inverted signal is disabled for gate 4 bit 8 g4d1n: gate 4 data source 1 negated enable bit 1 = the data source 1 inverted signal is enabled for gate 4 0 = the data source 1 inverted signal is disabled for gate 4 bit 7 g3d4t: gate 3 data source 4 true enable bit 1 = the data source 4 inverted signal is enabled for gate 3 0 = the data source 4 inverted signal is disabled for gate 3 bit 6 g3d4n: gate 3 data source 4 negated enable bit 1 = the data source 4 inverted signal is enabled for gate 3 0 = the data source 4 inverted signal is disabled for gate 3 bit 5 g3d3t: gate 3 data source 3 true enable bit 1 = the data source 3 inverted signal is enabled for gate 3 0 = the data source 3 inverted signal is disabled for gate 3 bit 4 g3d3n: gate 3 data source 3 negated enable bit 1 = the data source 3 inverted signal is enabled for gate 3 0 = the data source 3 inverted signal is disabled for gate 3 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 205 pic24fv16km204 family bit 3 g3d2t: gate 3 data source 2 true enable bit 1 = the data source 2 inverted signal is enabled for gate 3 0 = the data source 2 inverted signal is disabled for gate 3 bit 2 g3d2n: gate 3 data source 2 negated enable bit 1 = the data source 2 inverted signal is enabled for gate 3 0 = the data source 2 inverted signal is disabled for gate 3 bit 1 g3d1t: gate 3 data source 1 true enable bit 1 = the data source 1 inverted signal is enabled for gate 3 0 = the data source 1 inverted signal is disabled for gate 3 bit 0 g3d1n: gate 3 data source 1 negated enable bit 1 = the data source 1 inverted signal is enabled for gate 3 0 = the data source 1 inverted signal is disabled for gate 3 register 17-5: clcxglsh: clcx gate logic input select high register (continued) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 206 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 207 pic24fv16km204 family 18.0 high/low-voltage detect (hlvd) the high/low-voltage detect module (hlvd) is a programmable circuit that allows the user to specify both the device voltage trip point and the direction of change. an interrupt flag is set if the device experiences an excursion past the trip point in the direction of change. if the interrupt is enabled, the program execution will branch to the interrupt vector address and the software can then respond to the interrupt. the hlvd control register (see register 18-1 ) com- pletely controls the operation of the hlvd module. this allows the circuitry to be turned off by the user under software control, which minimizes the current consumption for the device. figure 18-1: high/low-voltage de tect (hlvd) module block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the high/low-voltage detect, refer to the pic24f family reference manual , high-level integration with programmable high/low-voltage detect (hlvd) (ds39725). set v dd 16-to-1 mux hlvden hlvdl<3:0> hlvdin v dd externally generated trip point hlvdif hlvden internal voltage reference vdir v bg C downloaded from: http:///
pic24fv16km204 family ds30003030b-page 208 ? 2013 microchip technology inc. register 18-1: hlvdcon: high/low-v oltage detect control register r/w-0 u-0 r/w-0 u-0 u-0 u-0 u-0 u-0 hlvden h l s i d l bit 15 bit 8 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 vdir bgvst irvst hlvdl3 hlvdl2 hlvdl1 hlvdl0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 hlvden: high/low-voltage detect power enable bit 1 = hlvd is enabled 0 = hlvd is disabled bit 14 unimplemented: read as 0 bit 13 hlsidl: hlvd stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12-8 unimplemented: read as 0 bit 7 vdir: voltage change direction select bit 1 = event occurs when voltage equals or exceeds trip point (hlvdl<3:0>) 0 = event occurs when voltage equals or falls below trip point (hlvdl<3:0>) bit 6 bgvst: band gap voltage stable flag bit 1 = indicates that the band gap voltage is stable 0 = indicates that the band gap voltage is unstable bit 5 irvst: internal reference voltage stable flag bit 1 = indicates that the internal reference voltage is stable and the high-voltage detect logic generates the interrupt flag at the specified voltage range 0 = indicates that the internal reference voltage is unstable and the high-voltage detect logic will not generate the interrupt flag at the specified voltage range, and the hlvd interrupt should not be enabled bit 4 unimplemented: read as 0 bit 3-0 hlvdl<3:0>: high/low-voltage detection limit bits 1111 = external analog input is used (input comes from the hlvdin pin) 1110 = trip point 1 ( 1 ) 1101 = trip point 2 ( 1 ) 1100 = trip point 3 ( 1 ) .. . 0000 = trip point 15 ( 1 ) note 1: for the actual trip point, see section 27.0 electrical characteristics . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 209 pic24fv16km204 family 19.0 12-bit a/d converter with threshold detect the pic24f 12-bit a/d converter has the following key features: successive approximation register (sar) conversion conversion speeds of up to 100 ksps up to 32 analog input channels (internal and external) multiple internal reference input channels external voltage reference input pins unipolar differential sample-and-hold (s/h) amplifier automated threshold scan and compare operation to pre-evaluate conversion results selectable conversion trigger source fixed-length (one word per channel), configurable conversion result buffer four options for results alignment configurable interrupt generation operation during cpu sleep and idle modes the 12-bit a/d converter module is an enhanced version of the 10-bit module offered in some pic24 devices. both modules are successive approximation register (sar) converters at their cores, surrounded by a range of hardware features for flexible configuration. this version of the module extends functionality by providing 12-bit resolution, a wider range of automatic sampling options and tighter integration with other analog modules, such as the ctmu, and a configurable results buffer. there is a legacy 10-bit mode on this a/d to allow the option to run with lower resolution in order to obtain higher throughput. this module also includes a unique threshold detect feature that allows the module itself to make simple decisions based on the conversion results. a simplified block diagram for the module is illustrated in figure 19-1 . note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the 12-bit a/d converter with threshold detect, refer to the pic24f family reference manual , 12-bit a/d converter with threshold detect (ds39739). downloaded from: http:///
pic24fv16km204 family ds30003030b-page 210 ? 2013 microchip technology inc. figure 19-1: 12-bit a/d converter block diagram comparator 10/12-bit sar v ref + dac an20 an21 an8 an9 an4 an5 an6 an7 an0 an1 an2 an3 v ref - sample control s/h av ss av dd adc1buf0: adc1buf17 ad1con1 ad1con2 ad1con3 ad1chs ad1chitl ad1chith control logic data formatting input mux control conversion control pin config. control internal 16 v r + v r - mux a v inh v inl v inh v inh v inl v inl v r + v r - v r select ctmu v bg ad1cssl ad1cssh avss 0.785 * v dd av dd 0.215 * v dd ad1con5 ctmu v bg te mp . s e n s o r data bus mux b conversion logic downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 211 pic24fv16km204 family to perform an a/d conversion: 1. configure the a/d module: a) configure the port pins as analog inputs and/or select band gap reference inputs (ansx registers). b) select the voltage reference source to match the expected range on the analog inputs (ad1con2<15:13>). c) select the analog conversion clock to match the desired data rate with the processor clock (ad1con3<7:0>). d) select the appropriate sample/conversion sequence (ad1con1<7:4> and ad1con3<12:8>). e) configure the mode12 bit to select a/d resolution (ad1con1<10>). f) select how conversion results are presented in the buffer (ad1con1<9:8>). g) select the interrupt rate (ad1con2<6:2>). h) turn on the a/d module (ad1con1<15>). 2. configure the a/d interrupt (if required): a) clear the ad1if bit. b) select the a/d interrupt priority. to perform an a/d sample and conversion using threshold detect scanning: 1. configure the a/d module: a) configure the port pins as analog inputs (ansx registers). b) select the voltage reference source to match the expected range on the analog inputs (ad1con2<15:13>). c) select the analog conversion clock to match the desired data rate with the processor clock (ad1con3<7:0>). d) select the appropriate sample/conversion sequence (ad1con1<7:4> and ad1con3<12:8>). e) configure the mode12 bit to select a/d resolution (ad1con1<10>). f) select how the conversion results are presented in the buffer (ad1con1<9:8>). g) select the interrupt rate (ad1con2<6:2>). 2. configure the threshold compare channels: a) enable auto-scan; set the asen bit (ad1con5<15>). b) select the compare mode, greater than, less than or windowed; set the cmx bits (ad1con5<1:0>). c) select the threshold compare channels to be scanned (ad1cssh, ad1cssl). d) if the ctmu is required as a current source for a threshold compare channel, enable the corresponding ctmu channel (ad1ctmenh, ad1ctmenl). e) write the threshold values into the corresponding adc1bufx registers. f) turn on the a/d module (ad1con1<15>). 3. configure the a/d interrupt (optional): a) clear the ad1if bit. b) select the a/d interrupt priority. note: if performing an a/d sample and conversion, using threshold detect in sleep mode, the rc a/d clock source must be selected before entering into sleep mode. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 212 ? 2013 microchip technology inc. 19.1 a/d control registers the 12-bit a/d converter module uses up to 43 registers for its operation. all registers are mapped in the data memory space. 19.1.1 control registers depending on the specific device, the module has up to eleven control and status registers: ad1con1: a/d control register 1 ad1con2: a/d control register 2 ad1con3: a/d control register 3 ad1con5: a/d control register 5 ad1chs: a/d sample select register ad1chith and ad1chitl: a/d scan compare hit registers ad1cssh and ad1cssl: a/d input scan select registers ad1ctmenh and ad1ctmenl: ctmu enable registers the ad1con1, ad1con2 and ad1con3 registers ( register 19-1 , register 19-2 and register 19-3 ) control the overall operation of the a/d module. this includes enabling the module, configuring the conversion clock and voltage reference sources, selecting the sampling and conversion triggers, and manually controlling the sample/convert sequences. the ad1con5 register ( register 19-4 ) specifically controls features of the threshold detect operation, including its function in power-saving modes. the ad1chs register ( register 19-5 ) selects the input channels to be connected to the s/h amplifier. it also allows the choice of input multiplexers and the selection of a reference source for differential sampling. the ad1chith and ad1chitl registers ( register 19-6 and register 19-7 ) are semaphore registers used with threshold detect operations. the status of individual bits, or bit pairs in some cases, indicates if a match condition has occurred. ad1chitl is always implemented, whereas ad1chith may not be implemented in devices with 16 or fewer channels. the ad1cssh/l registers ( register 19-8 and register 19-9 ) select the channels to be included for sequential scanning. the ad1ctmenh/l registers ( register 19-10 and register 19-11 ) select the channel(s) to be used by the ctmu during conversions. selecting a particular channel allows the a/d converter to control the ctmu (particularly, its current source) and read its data through that channel. ad1ctmenl is always implemented, whereas ad1ctmenh may not be implemented in devices with 16 or fewer channels. 19.1.2 a/d result buffers the module incorporates a multi-word, dual port buffer, called adc1bufx. each of the locations is mapped into the data memory space and is separately addressable. the buffer locations are referred to as adc1buf0 through adc1bufx (x = up to 17). the a/d result buffers are both readable and writable. when the module is active (ad1con<15> = 1 ), the buffers are read-only and store the results of a/d conversions. when the module is inactive (ad1con<15> = 0 ), the buffers are both readable and writable. in this state, writing to a buffer location programs a conversion threshold for threshold detect operations. buffer contents are not cleared when the module is deactivated with the adon bit (ad1con1<15>). conversion results and any programmed threshold values are maintained when adon is set or cleared. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 213 pic24fv16km204 family register 19-1: ad1con1: a/da/d control register 1 r/w-0 u-0 r/w-0 u-0 u-0 r/w-0 r/w-0 r/w-0 adon a d s i d l m o d e 1 2f o r m 1f o r m 0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0, hsc r/c-0, hsc ssrc3 ssrc2 ssrc1 ssrc0 asam samp done bit 7 bit 0 legend: c = clearable bit u = unimplemented bit, read as 0 r = readable bit w = writable bit hsc = hardware settable/clearable bit -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 adon: a/d operating mode bit 1 = a/d converter is operating 0 = a/d converter is off bit 14 unimplemented: read as 0 bit 13 adsidl: a/d stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12-11 unimplemented: read as 0 bit 10 mode12: 12-bit a/d operation mode bit 1 = 12-bit a/d operation 0 = 10-bit a/d operation bit 9-8 form<1:0>: data output format bits (see the following formats) 11 = fractional result, signed, left justified 10 = absolute fractional result, unsigned, left justified 01 = decimal result, signed, right justified 00 = absolute decimal result, unsigned, right justified bit 7-4 ssrc<3:0>: sample clock source select bits 1111 = reserved 1101 = reserved 1100 = clc2 event ends sampling and starts conversion 1011 = sccp4 compare event (ccp4if) ends sampling and starts conversion 1010 = mccp3 compare event (ccp3if) ends sampling and starts conversion 1001 = mccp2 compare event (ccp2if) ends sampling and starts conversion 1000 = clc1 event ends sampling and starts conversion 0111 = internal counter ends sampling and starts conversion (auto-convert) 0110 = tmr1 sleep mode trigger event ends sampling and starts conversion ( 1 ) 0101 = tmr1 event ends sampling and starts conversion 0100 = ctmu event ends sampling and starts conversion 0011 = sccp5 compare event (ccp5if) ends sampling and starts conversion 0010 = mccp1 compare event (ccp1if) ends sampling and starts conversion 0001 = int0 event ends sampling and starts conversion 0000 = clearing the sample bit ends sampling and starts conversion note 1: this version of the tmr1 trigger allows a/d conversions to be triggered from tmr1 while the device is operating in sleep mode. the ssrc<3:0> = 0101 option allows conversions to be triggered in run or idle modes only. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 214 ? 2013 microchip technology inc. bit 3 unimplemented: read as 0 bit 2 asam: a/d sample auto-start bit 1 = sampling begins immediately after the last conversion; samp bit is auto-set 0 = sampling begins when the samp bit is manually set bit 1 samp: a/d sample enable bit 1 = a/d sample-and-hold amplifiers are sampling 0 = a/d sample-and-hold amplifiers are holding bit 0 done: a/d conversion status bit 1 = a/d conversion cycle has completed 0 = a/d conversion cycle has not started or is in progress register 19-1: ad1con1: a/da/d control register 1 (continued) note 1: this version of the tmr1 trigger allows a/d conversions to be triggered from tmr1 while the device is operating in sleep mode. the ssrc<3:0> = 0101 option allows conversions to be triggered in run or idle modes only. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 215 pic24fv16km204 family register 19-2: ad1con2: a/d control register 2 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 u-0 u-0 pvcfg1 pvcfg0 nvcfg0 bufregen cscna bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 bufs ( 1 ) smpi4 smpi3 smpi2 smpi1 smpi0 bufm ( 1 ) alts bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-14 pvcfg<1:0>: a/d converter positive voltage reference configuration bits 11 = 4 * internal v bg ( 2 ) 10 = 2 * internal v bg ( 3 ) 01 =external v ref + 00 =av dd bit 13 nvcfg0: a/d converter negative voltage reference configuration bits 1 =external v ref - 0 =av ss bit 12 unimplemented: read as 0 bit 11 bufregen: a/d buffer register enable bit 1 = conversion result is loaded into a buffer location determined by the converted channel 0 = a/d result buffer is treated as a fifo bit 10 cscna: scan input selections for ch0+ s/h input for mux a setting bit 1 =scans inputs 0 = does not scan inputs bit 9-8 unimplemented: read as 0 bit 7 bufs: a/d buffer fill status bit ( 1 ) 1 = a/d is filling the upper half of the buffer; user should access data in the lower half 0 = a/d is filling the lower half of the buffer; user should access data in the upper half bit 6-2 smpi<4:0>: interrupt sample rate select bits 11111 = interrupts at the completion of the conversion for each 32nd sample 11110 = interrupts at the completion of the conversion for each 31st sample 00001 = interrupts at the completion of the conversion for every other sample 00000 = interrupts at the completion of the conversion for each sample bit 1 bufm: a/d buffer fill mode select bit ( 1 ) 1 = starts filling the buffer at address, adc1buf0, on the first interrupt and adc1buf(x/2) on the next interrupt (split buffer mode) 0 = starts filling the buffer at address, adc1buf0, and each sequential addres s on successive interrupts (fifo mode) bit 0 alts: alternate input sample mode select bit 1 = uses channel input selects for sample a on the first sample and sample b on the next sample 0 = always uses channel input selects for sample a note 1: this is only applicable when the buffer is used in fifo mode (bufregen = 0 ). in addition, bufs is only used when bufm = 1 . 2: pic24fv16kmxxx devices only. reference setting will not be within specification for v dd below 4.5v. 3: reference setting will not be within specification for v dd below 2.3v. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 216 ? 2013 microchip technology inc. register 19-3: ad1con3: a/d control register 3 r/w-0 r-0 r-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 adrc extsam r samc4 samc3 samc2 samc1 samc0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 adcs7 adcs6 adcs5 adcs4 adcs3 adcs2 adcs1 adcs0 bit 7 bit 0 legend: r = reserved bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 adrc: a/d conversion clock source bit 1 = rc clock 0 = clock is derived from the system clock bit 14 extsam: extended sampling time bit 1 = a/d is still sampling after samp = 0 0 = a/d is finished sampling bit 13 reserved: maintain as 0 bit 12-8 samc<4:0>: auto-sample time select bits 11111 = 31 t ad 00001 =1 t ad 00000 =0 t ad bit 7-0 adcs<7:0>: a/d conversion clock select bits 11111111 - 01000000 = reserved 00111111 = 64 * t cy =t ad 00000001 = 2 * t cy =t ad 00000000 = t cy =t ad downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 217 pic24fv16km204 family register 19-4: ad1con5: a/d control register 5 r/w-0 r/w-0 r/w-0 r/w-0 r-0 u-0 r/w-0 r/w-0 asen ( 1 ) lpen ctmreq bgreq r asint1 asint0 bit 15 bit 8 u-0 u-0 u-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 w m 1w m 0c m 1c m 0 bit 7 bit 0 legend: r = reserved bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 asen: a/d auto-scan enable bit ( 1 ) 1 = auto-scan is enabled 0 = auto-scan is disabled bit 14 lpen: a/d low-power enable bit 1 = returns to low-power mode after scan 0 = remains in full-power mode after scan bit 13 ctmreq: ctmu request bit 1 = ctmu is enabled when the a/d is enabled and active 0 = ctmu is not enabled by the a/d bit 12 bgreq: band gap request bit 1 = band gap is enabled when the a/d is enabled and active 0 = band gap is not enabled by the a/d bit 11 reserved: maintain as 0 bit 10 unimplemented: read as 0 bit 9-8 asint<1:0>: auto-scan (threshold detect) interrupt mode bits 11 = interrupt after a threshold detect sequence has completed and a valid compare has occurred 10 = interrupt after a valid compare has occurred 01 = interrupt after a threshold detect sequence has completed 00 = no interrupt bit 7-4 unimplemented: read as 0 bit 3-2 wm<1:0>: a/d write mode bits 11 = reserved 10 = auto-compare only (conversion results are not saved, but interrupt s are generated when a valid match, as defined by the cmx and asintx bits, occurs) 01 = convert and save (conversion results are saved to locations as determined by the register bits when a match, as defined by the cmx bits, occurs) 00 = legacy operation (conversion data is saved to a location determined by the buffer register bits) bit 1-0 cm<1:0>: a/d compare mode bits 11 = outside window mode (valid match occurs if the conversion result is outside of the wi ndow defined by the corresponding buffer pair) 10 = inside window mode (valid match occurs if the conversion result is inside the window defined by the corresponding buffer pair) 01 = greater than mode (valid match occurs if the result is greater than the v alue in the corresponding buffer register) 00 = less than mode (valid match occurs if the result is less than the value in the corresponding buffer register) note 1: when using auto-scan with threshold detect (asen = 1 ), do not configure the sample clock source to auto-convert mode (ssrc<3:0> = 7). any other available ssrc selection is valid. to use auto-convert as the sample clock source (ssrc<3:0> = 7), make sure asen is cleared. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 218 ? 2013 microchip technology inc. register 19-5: ad1chs: a/d sample select register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ch0nb2 ch0nb1 ch0nb0 ch0sb4 ch0sb3 ch0sb2 ch0sb1 ch0sb0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ch0na2 ch0na1 ch0na0 ch0sa4 ch0sa3 ch0sa2 ch0sa1 ch0sa0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-13 ch0nb<2:0>: sample b channel 0 negative input select bits 111 = an6 ( 1 ) 110 = an5 ( 2 ) 101 = an4 100 = an3 011 = an2 010 = an1 001 = an0 000 = av ss bit 12-8 ch0sb<4:0>: s/h amplifier positive input select for mux b multiplexer setting bits 11111 = unimplemented, do not use 11110 =av dd ( 3 ) 11101 =av ss ( 3 ) 11100 = upper guardband rail (0.785 * v dd ) 11011 = lower guardband rail (0.215 * v dd ) 11010 = internal band gap reference (v bg ) ( 3 ) 11000 - 11001 = unimplemented, do not use 10001 = no channels are connected, all inputs are floating (used for ctmu) 10111 = no channels are connected, all inputs are floating (used for ctmu) 10110 = no channels are connected, all inputs are floating (used for ctmu temperature sensor input); does not require the corresponding ctmen22 (ad1ctmenh<6>) bit) 10101 = channel 0 positive input is an21 10100 = channel 0 positive input is an20 10011 = channel 0 positive input is an19 10010 = channel 0 positive input is an18 ( 2 ) 10001 = channel 0 positive input is an17 ( 2 ) 01001 = channel 0 positive input is an9 01000 = channel 0 positive input is an8 ( 1 ) 00111 = channel 0 positive input is an7 ( 1 ) 00110 = channel 0 positive input is an6 ( 1 ) 00101 = channel 0 positive input is an5 ( 2 ) 00100 = channel 0 positive input is an4 00011 = channel 0 positive input is an3 00010 = channel 0 positive input is an2 00001 = channel 0 positive input is an1 00000 = channel 0 positive input is an0 note 1: this is implemented on 44-pin devices only. 2: this is implemented on 28-pin and 44-pin devices only. 3: the band gap value used for this input is 2x or 4x the internal v bg , which is selected when pvcfg<1:0> = 1x . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 219 pic24fv16km204 family bit 7-5 ch0na<2:0>: sample a channel 0 negative input select bits the same definitions as for chonb<2:0>. bit 4-0 ch0sa<4:0>: sample a channel 0 positive input select bits the same definitions as for chona<4:0>. register 19-5: ad1chs: a/d sample select register (continued) note 1: this is implemented on 44-pin devices only. 2: this is implemented on 28-pin and 44-pin devices only. 3: the band gap value used for this input is 2x or 4x the internal v bg , which is selected when pvcfg<1:0> = 1x . register 19-6: ad1chith: a/d scan compare hit register (high word) ( 1 ) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 chh23 chh22 chh21 chh20 ( 2 ) chh19 ( 2 ) chh18 chh17 chh16 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 . bit 7-0 chh<23:16>: a/d compare hit bits ( 2 ) if cm<1:0> = 11 : 1 = a/d result buffer x has been written with data or a match has occurred 0 = a/d result buffer x has not been written with data for all other values of cm<1:0>: 1 = a match has occurred on a/d result channel x 0 = no match has occurred on a/d result channel x note 1: unimplemented channels are read as 0 . 2: the chh<20:19> bits are not implemented in 20-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 220 ? 2013 microchip technology inc. register 19-7: ad1chitl: a/d scan compare hit register (low word) ( 1 ) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 chh15 chh14 chh13 chh12 chh11 chh10 chh9 chh8 ( 2 , 3 ) bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 chh7 ( 2 , 3 ) chh6 ( 2 , 3 ) chh5 ( 2 ) chh4 chh3 chh2 chh1 chh0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-0 chh<15:0>: a/d compare hit bits ( 2 , 3 ) if cm<1:0> = 11 : 1 = a/d result buffer x has been written with data or a match has occurred 0 = a/d result buffer x has not been written with data for all other values of cm<1:0>: 1 = a match has occurred on a/d result channel x 0 = no match has occurred on a/d result channel x note 1: unimplemented channels are read as 0 . 2: the chh<8:5> bits are not implemented in 20-pin devices. 3: the chh<8:6> bits are not implemented in 28-pin devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 221 pic24fv16km204 family register 19-8: ad1cssh: a/d input scan select register (high word) ( 1 ) u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 css30 css29 css28 css27 css26 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 css23 css22 css21 css20 ( 2 ) css19 ( 2 ) css18 css17 css16 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 unimplemented: read as 0 bit 14-10 css<30:26>: a/d input scan selection bits 1 = includes the corresponding channel for input scan 0 = skips the channel for input scan bit 9-8 unimplemented: read as 0 bit 7-0 css<23:16>: a/d input scan selection bits ( 2 ) 1 = includes the corresponding channel for input scan 0 = skips the channel for input scan note 1: unimplemented channels are read as 0 . do not select unimplemented channels for sampling as indeterminate results may be produced. 2: the css<20:19> bits are not implemented in 20-pin devices. register 19-9: ad1cssl: a/d input scan select register (low word) ( 1 ) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 css15 css14 css13 css12 css11 css10 css9 css8 ( 2 , 3 ) bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 css7 ( 2 , 3 ) css6 ( 2 , 3 ) css5 ( 2 ) css4 css3 css2 css1 css0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-0 css<15:0>: a/d input scan selection bits ( 2 , 3 ) 1 = includes the corresponding anx input for scan 0 = skips the channel for input scan note 1: unimplemented channels are read as 0 . do not select unimplemented channels for sampling as indeterminate results may be produced. 2: the css<8:5> bits are not implemented in 20-pin devices. 3: the css<8:6> bits are not implemented in 28-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 222 ? 2013 microchip technology inc. register 19-10: ad1ctmenh: ctmu enable register (high word) ( 1 ) u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ctmen23 ctmen22 ctmen21 ctmen20 ( 2 ) ctmen19 ( 2 ) ctmen18 ctmen17 ctmen16 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 . bit 7-0 ctmen<23:16>: ctmu enabled during conversion bits ( 2 ) 1 = ctmu is enabled and connected to the selected channel during conversion 0 = ctmu is not connected to this channel note 1: unimplemented channels are read as 0 . 2: the ctmen<20:19> bits are not implemented in 20-pin devices. register 19-11: ad1ctmenl: ctmu enable register (low word) ( 1 ) r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ctmen15 ctmen14 ctmen13 ctmen12 ctmen11 ctmen10 ctmen9 ctmen8 ( 2 , 3 ) bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ctmen7 ( 2 , 3 ) ctmen6 ( 2 , 3 ) ctmen5 ( 2 ) ctmen4 ctmen3 ctme n2 ctmen1 ctmen0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-0 ctmen<15:0>: ctmu enabled during conversion bits ( 2 , 3 ) 1 = ctmu is enabled and connected to the selected channel during conversion 0 = ctmu is not connected to this channel note 1: unimplemented channels are read as 0 . 2: the ctmen<8:5> bits are not implemented in 20-pin devices. 3: the ctmen<8:6> bits are not implemented in 28-pin devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 223 pic24fv16km204 family 19.2 a/d sampling requirements the analog input model of the 12-bit a/d converter is shown in figure 19-2 . the total sampling time for the a/d is a function of the holding capacitor charge time. for the a/d converter to meet its specified accuracy, the charge holding capacitor (c hold ) must be allowed to fully charge to the voltage level on the analog input pin. the source impedance (r s ), the interconnect imped- ance (r ic ) and the internal sampling switch impedance (r ss ) combine to directly affect the time required to charge c hold . the combined impedance of the analog sources must, therefore, be small enough to fully charge the holding capacitor within the chosen sample time. to minimize the effects of pin leakage currents on the accu- racy of the a/d converter, the maximum recommended source impedance, r s , is 2.5 k ? . after the analog input channel is selected (changed), this sampling function must be completed prior to starting the conversion. the internal holding capacitor will be in a discharged state prior to each sample operation. at least 1 t ad time period should be allowed between conversions for the sample time. for more details, see section 27.0 electrical characteristics . equation 19-1: a/d conversion clock period figure 19-2: 12-bit a/d converter analog input model note: based on t cy = 2/f osc ; doze mode and pll are disabled. t ad = t cy (adcs + 1 ) adcs = t ad t cy ? 1 c pin rs anx i leakage r ic ? 250 ? sampling switch r ss c hold v ss = 32 pf ? 500 na legend: c pin v t i leakage r ic r ss c hold = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch resistance = sample-and-hold capacitance (from dac) various junctions note: the c pin value depends on the device package and is not tested. the effect of c pin is negligible if rs ? 5 k ? . va r ss ? 3 k ? downloaded from: http:///
pic24fv16km204 family ds30003030b-page 224 ? 2013 microchip technology inc. 19.3 transfer function the transfer functions of the a/d converter in 12-bit resolution are shown in figure 19-3 . the difference of the input voltages (v inh C v inl ) is compared to the reference ((v r +) C (v r -)). the first code transition occurs when the input voltage is ((v r +) C (v r -))/4096 or 1.0 lsb. the 0000 0000 0001 code is centered at v r - + (1.5 * ((v r +) C (v r -))/4096). the 0010 0000 0000 code is centered at v refl + (2048.5 * ((v r +) C (v r -))/4096). an input voltage less than v r - + (((v r -) C (v r -))/4096) converts as 0000 0000 0000 . an input voltage greater than (v r -) + (4095 ((v r +) C (v r -))/4096) converts as 1111 1111 1111 . figure 19-3: 12-bit a/ d transfer function 0010 0000 0001 (2049) 0010 0000 0010 (2050) 0010 0000 0011 (2051) 0001 1111 1101 (2045) 0001 1111 1110 (2046) 0001 1111 1111 (2047) 1111 1111 1110 (4094) 1111 1111 1111 (4095) 0000 0000 0000 (0) 0000 0000 0001 (1) output code 0010 0000 0000 (2048) (v inh C v inl ) v r- v r+ C v r- 4096 2048 * (v r+ C v r- ) 4096 v r+ v r- + v r- + 4095 * (v r+ C v r- ) 4096 v r- + 0 (binary (decimal)) voltage level downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 225 pic24fv16km204 family 19.4 buffer data formats the a/d conversions are fully differential 12-bit values when mode12 = 1 (ad1con1<10>) and 10-bit values when mode12 = 0 . when absolute fractional or abso- lute integer formats are used, the results are 12 or 10 bits wide, respectively. when signed decimal format- ting is used, the conversion also includes a sign bit, making 12-bit conversions 13 bits wide and 10-bit conversions 11 bits wide. the signed decimal format yields 12-bit and 10-bit values, respectively. the sign bit (bit 12 or bit 10) is sign-extended to fill the buffer. the form<1:0> bits (ad1con1<9:8>) select the format. figure 19-4 and figure 19-5 show the data output formats that can be selected. table 19-1 through table 19-4 show the numerical equivalents for the various conversion result codes. figure 19-4: a/d output data formats (12-bit) table 19-1: numerical equivalents of various result codes: 12-bit integer formats ram contents: d11 d10 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 read to bus: integer 0000 d11 d10 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 signed integer s0 s0 s0 s0 d11 d10 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 fractional (1.15) d11 d10 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 0000 signed fractional (1.15) s0 d11 d10 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 000 v in /v ref 12-bit differential output code (13-bit result) 16-bit integer format/ equivalent decimal value 16-bit signed integer format/ equivalent decimal value +4095/4096 0 1111 1111 1111 0000 1111 1111 1111 +4095 0000 1111 1111 1111 +4095 +4094/4096 0 1111 1111 1110 0000 1111 1111 1110 +4094 0000 1111 1111 1110 +4094 ????? +1/4096 0 1000 0000 0001 0000 0000 0000 0001 +1 0000 0000 0000 0001 +1 0/4096 0 0000 0000 0000 0000 0000 0000 0000 0 0000 0000 0000 0000 0 -1/4096 1 0111 1111 1111 0000 0000 0000 0000 0 1111 1111 1111 1111 -1 ????? -4095/4096 1 0000 0000 0001 0000 0000 0000 0000 0 1111 0000 0000 0001 -4095 -4096/4096 1 0000 0000 0000 0000 0000 0000 0000 0 1111 0000 0000 0000 -4096 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 226 ? 2013 microchip technology inc. table 19-2: numerical equivalents of various result codes: 12-bit fractional formats figure 19-5: a/d output data formats (10-bit) table 19-3: numerical equivalents of various result codes: 10-bit integer formats v in /v ref 12-bit output code 16-bit fractional format/ equivalent decimal value 16-bit signed fractional format/ equivalent decimal value +4095/4096 0 1111 1111 1111 1111 1111 1111 0000 0.999 0111 1111 1111 1000 0.999 +4094/4096 0 1111 1111 1110 1111 1111 1110 0000 0.998 0111 1111 1110 1000 0.998 ????? +1/4096 0 0000 0000 0001 0000 0000 0001 0000 0.001 0000 0000 0000 1000 0.001 0/4096 0 0000 0000 0000 0000 0000 0000 0000 0.000 0000 0000 0000 0000 0.000 -1/4096 1 0111 1111 1111 0000 0000 0000 0000 0.000 1111 1111 1111 1000 -0.001 ????? -4095/4096 1 0000 0000 0001 0000 0000 0000 0000 0.000 1000 0000 0000 1000 -0.999 -4096/4096 1 0000 0000 0000 0000 0000 0000 0000 0.000 1000 0000 0000 0000 -1.000 ram contents: d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 read to bus: integer 000000 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 signed integer s0 s0 s0 s0 s0 s0 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 fractional (1.15) d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 000000 signed fractional (1.15) s0 d09 d08 d07 d06 d05 d04 d03 d02 d01 d00 00000 v in /v ref 10-bit differential output code (11-bit result) 16-bit integer format/ equivalent decimal value 16-bit signed integer format/ equivalent decimal value +1023/1024 011 1111 1111 0000 0011 1111 1111 1023 0000 0001 1111 1111 1023 +1022/1024 011 1111 1110 0000 0011 1111 1110 1022 0000 0001 1111 1110 1022 ????? +1/1024 000 0000 0001 0000 0000 0000 0001 1 0000 0000 0000 0001 1 0/1024 000 0000 0000 0000 0000 0000 0000 0 0000 0000 0000 0000 0 -1/1024 101 1111 1111 0000 0000 0000 0000 0 1111 1111 1111 1111 -1 ????? -1023/1024 100 0000 0001 0000 0000 0000 0000 0 1111 1110 0000 0001 -1023 -1024/1024 100 0000 0000 0000 0000 0000 0000 0 1111 1110 0000 0000 -1024 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 227 pic24fv16km204 family table 19-4: numerical equivalents of various result codes: 10-bit fractional formats v in /v ref 10-bit differential output code (11-bit result) 16-bit fractional format/ equivalent decimal value 16-bit signed fractional format/ equivalent decimal value +1023/1024 011 1111 1111 1111 1111 1100 0000 0.999 0111 1111 1110 0000 0.999 +1022/1024 011 1111 1110 1111 1111 1000 0000 0.998 0111 1111 1000 0000 0.998 ??? +1/1024 000 0000 0001 0000 0000 0100 0000 0.001 0000 0000 0010 0000 0.001 0/1024 000 0000 0000 0000 0000 0000 0000 0.000 0000 0000 0000 0000 0.000 -1/1024 101 1111 1111 0000 0000 0000 0000 0.000 1111 1111 1110 0000 -0.001 ??? -1023/1024 100 0000 0001 0000 0000 0000 0000 0.000 1000 0000 0010 0000 -0.999 -1024/1024 100 0000 0000 0000 0000 0000 0000 0.000 1000 0000 0000 0000 -1.000 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 228 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 229 pic24fv16km204 family 20.0 8-bit digital-to-analog converter (dac) pic24fv16km204 family devices include two 8-bit digital-to-analog converters (dacs) for generating analog outputs from digital data. a simplified block diagram for a single dac is shown in figure 20-1 . both of the dacs are identical. the dac generates an analog output voltage based on the digital input code, according to the formula: where v dac is the analog output voltage and v dacref is the reference voltage selected by dacref<1:0>. each dac includes these features: precision 8-bit resistor ladder for high accuracy fast settling time, supporting 1 msps effective sampling rates buffered output voltage three user-selectable voltage reference options multiple conversion trigger options, plus a manual convert-on-write option left and right justified input data options user-selectable sleep and idle mode operation when using the dac, it is recommended to set the ansx and trisx bits for the dacx output pin to configure it as an analog output. see section 11.2 configuring analog port pins for more information. figure 20-1: single dacx simplified block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information, refer to the pic24f family reference manual . device-specific information in this data sheet supersedes the information in the pic24f family reference manual . v dacref ? dacxdat 256 v dac = dacxcon resistor ladder avss 8 dactsel<4:0> trigger and interrupt logic dacxif dacxref av dd bgbuf1 dacref<1:0> dacxout dacen dacsidl idle mode dacslp sleep mode dactrig 8-bit pin 32 dacx trigger sources dacxdat dacoe downloaded from: http:///
pic24fv16km204 family ds30003030b-page 230 ? 2013 microchip technology inc. register 20-1: dacxcon: dacx control register r/w-0 u-0 r/w-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 dacen dacsidl dacslp dacfm srdis dactrig bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 dacoe dactsel4 dactsel3 dactsel2 d actsel1 dactsel0 dacref1 dacref0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 dacen: dacx enable bit 1 = module is enabled 0 = module is disabled bit 14 unimplemented: read as 0 bit 13 dacsidl: dacx stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12 dacslp: dacx enable peripheral during sleep bit 1 = dacx continues to output the most recent value of dacxdat during sleep mode 0 = dacx is powered down in sleep mode; dacxout pin is controlled by the trisx and latx bits bit 11 dacfm: dacx data format select bit 1 = data is left justified (data stored in dacxdat<15:8>) 0 = data is right justified (data stored in dacxdat<7:0>) bit 10 unimplemented: read as 0 bit 9 srdis: soft reset disable bit 1 = dacxcon and dacxdat sfrs reset only on a por or bor reset 0 = dacxcon and dacxdat sfrs reset on any type of device reset bit 8 dactrig: dacx trigger input enable bit 1 = analog output value updates when the selected (by dactsel<4:0>) event occurs 0 = analog output value updates as soon as dacxdat is written (dac trigger is ignored) bit 7 dacoe: dacx output enable bit 1 = dacx output pin is enabled and driven on the dacxout pin 0 = dacx output pin is disabled, dacx output is available internally to other peripherals only note 1: bgbuf1 voltage is configured by bufref<1:0> (bufcon0<1:0>). downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 231 pic24fv16km204 family bit 6-2 dactsel<4:0>: dacx trigger source select bits 11101-11111 = unused 11100 = ctmu 11011 = a/d 11010 = comparator 3 11001 = comparator 2 11000 = comparator 1 10011 to 10111 = unused 10010 = clc2 output 10001 = clc1 output 01100 to 10000 = unused 01011 = timer1 sync output 01010 = external interrupt 2 01001 = external interrupt 1 01000 = external interrupt 0 0011x = unused 00101 = mccp5 or sccp5 sync output 00100 = mccp4 or sccp4 sync output 00011 = mccp3 or sccp3 sync output 00010 = mccp2 or sccp2 sync output 00001 = mccp1 or sccp1 sync output 00000 = unused bit 1-0 dacref<1:0>: dacx reference source select bits 11 = internal band gap buffer 1 (bgbuf1) ( 1 ) 10 =av dd 01 =dv ref + 00 = reference is not connected (lowest power but no dac functionality) register 20-1: dacxcon: dacx control register (continued) note 1: bgbuf1 voltage is configured by bufref<1:0> (bufcon0<1:0>). downloaded from: http:///
pic24fv16km204 family ds30003030b-page 232 ? 2013 microchip technology inc. register 20-2: bufcon0: internal volt age reference control register 0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 u-0 r/w-0 r/w-1 bufref1 bufref0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-2 unimplemented: read as 0 bit 1-0 bufref<1:0>: internal voltage reference select bits 11 = reference output is set at 4 * bgbuf1 ( 1 ) 10 = reference output is set at 2 * bgbuf1 ( 2 ) 01 = reference output is set at bgbuf1 00 = reserved, do not use note 1: available only on pic24fv16kmxxx devices. the reference may not be within specifications for v dd below specified levels; see table 27-15 for minimum v dd limits. 2: the reference may not be within specifications for v dd below specified levels; see table 27-15 for minimum v dd limits. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 233 pic24fv16km204 family 21.0 dual operational amplifier module pic24fv16km204 family devices include two opera- tional amplifiers to complement the microcontrollers other analog features. they may be used to provide analog signal conditioning, either as stand-alone devices or in addition to other analog peripherals. the two op amps are functionally identical; the block diagram for a single amplifier is shown in figure 21-1 . each op amp has these features: internal unity-gain buffer option multiple input options each on the inverting and non-inverting amplifier inputs rail-to-rail input and output capabilities user-selectable option for regular or low-power operation user-selectable operation in idle and sleep modes when using the op amps, it is recommended to set the ansx and trisx bits of both the input and output pins to configure them as analog pins. see section 11.2 configuring analog port pins for more information. figure 21-1: single operatio nal amplifier block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information, refer to the pic24f family reference manual , operational amplifier (op amp) (ds30505). device-specific information in this data sheet supersedes the information in the pic24f family reference manual . spdsel + C ampen oaxout ampsidl ampslp ninsel<2:0> pinsel<2:0> oaxinb oaxind a vss ctmu/a/d oaxina oaxinc dacx out a vss downloaded from: http:///
pic24fv16km204 family ds30003030b-page 234 ? 2013 microchip technology inc. register 21-1: ampxcon: op amp x control register ( 1 ) r/w-0 u-0 r/w-0 r/w-0 u-0 u-0 u-0 u-0 ampen ampsidl ampslp bit 15 bit 8 r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 spdsel ninsel2 ninsel1 ninsel0 pinsel2 pinsel1 pinsel0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 ampen: op amp x control module enable bit 1 = module is enabled 0 = module is disabled bit 14 unimplemented: read as 0 bit 13 ampsidl: op amp x peripheral stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12 ampslp: op amp x peripheral enabled in sleep mode bit 1 = continues module operation when device enters sleep mode 0 = discontinues module operation in sleep mode bit 11-8 unimplemented: read as 0 bit 7 spdsel: op amp x power/speed select bit 1 = higher power and bandwidth (faster response time) 0 = lower power and bandwidth (slower response time) bit 6 unimplemented: read as 0 bit 5-3 ninsel<2:0>: negative op amp input select bits 111 = reserved; do not use 110 = reserved; do not use 101 = op amp negative input is connected to the op amp output (voltage follower) 100 = reserved; do not use 011 = reserved; do not use 010 = op amp negative input is connected to the oaxind pin 001 = op amp negative input is connected to the oaxinb pin 000 = op amp negative input is connected to av ss bit 2-0 pinsel<2:0>: positive op amp input select bits 111 = op amp positive input is connected to the output of the a/d input multiplexer 110 = reserved; do not use 101 = op amp positive input is connected to the dac1 output for oa1 (dac2 output for oa2) 100 = reserved; do not use 011 = reserved; do not use 010 = op amp positive input is connected to the oaxinc pin 001 = op amp positive input is connected to the oaxina pin 000 = op amp positive input is connected to av ss note 1: this register is available only on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 235 pic24fv16km204 family 22.0 comparator module the comparator module provides three dual input comparators. the inputs to the comparator can be configured to use any one of four external analog inputs, as well as a voltage reference input from either the internal band gap buffer 1 (bgbuf1) or the com- parator voltage reference generator. the comparator outputs may be directly connected to the cxout pins. when the respective coe bit equals 1 , the i/o pad logic makes the unsynchronized output of the comparator available on the pin. a simplified block diagram of the module is shown in figure 22-1 . diagrams of the possible individual comparator configurations are shown in figure 22-2 . each comparator has its own control register, cmxcon ( register 22-1 ), for enabling and configuring its operation. the output and event status of all three comparators is provided in the cmstat register ( register 22-2 ). figure 22-1: comparator x module block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive refer- ence source. for more information on the comparator module, refer to the pic24f family reference manual , scalable comparator module (ds39734). c1 v in - v in + c x inb c x inc c x ina c x ind cv ref bgbuf1 c3 v in - v in + coe c1out pin cpol cevt evpol<1:0> cout input select logic cch<1:0> cref<1:0> coe c3out pin cpol cevt evpol<1:0> cout c2 v in - v in + coe c2out pin cpol cevt cout trigger/interrupt logic trigger/interrupt logic evpol<1:0> trigger/interrupt logic downloaded from: http:///
pic24fv16km204 family ds30003030b-page 236 ? 2013 microchip technology inc. figure 22-2: individual comparator configurations cx v in - v in + off (read as 0 ) comparator off con = 0 , cref<1:0> = xx , cch<1:0> = xx comparator cxinb > cxina compare con = 1 , cref<1:0> = 00 , cch<1:0> = 00 coe cxout cx v in - v in + coe c x inb c x ina comparator cxind > cxina compare con = 1 , cref<1:0> = 00 , cch<1:0> = 10 cx v in - v in + coe cxout c x ind c x ina comparator cxinc > cxina compare con = 1 , cref<1:0> = 00 , cch<1:0> = 01 cx v in - v in + coe c x inc c x ina comparator bgbuf1 > cxina compare con = 1 , cref<1:0> = 00 , cch<1:0> = 11 cx v in - v in + coe bgbuf1 c x ina comparator cxinb > cv ref compare con = 1 , cref<1:0> = 01 , cch<1:0> = 00 cx v in - v in + coe c x inb cv ref comparator cxind > dac1out compare con = 1 , cref<1:0> = 10 , cch<1:0> = 10 cx v in - v in + coe c x ind dac1out comparator cxinc > cv ref compare con = 1 , cref<1:0> = 01 , cch<1:0> = 01 cx v in - v in + coe c x inc cv ref comparator bgbuf1 > dac2out compare con = 1 , cref<1:0> = 11 , cch<1:0> = 11 cx v in - v in + coe bgbuf1 dac2out pin pin cxout pin cxout pin cxout pin cxout pin cxout pin cxout pin cxout pin C CC C C C C C C downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 237 pic24fv16km204 family register 22-1: cmxcon: comp arator x control registers r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 r/w-0 r-0 con coe cpol clpwr cevt cout bit 15 bit 8 r/w-0 r/w-0 u-0 r/w-0 r/w-0 u-0 r/w-0 r/w-0 evpol1 ( 2 ) evpol0 ( 2 ) cref1 cref0 cch1 cch0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 con: comparator x enable bit 1 = comparator is enabled 0 = comparator is disabled bit 14 coe: comparator x output enable bit 1 = comparator output is present on the cxout pin 0 = comparator output is internal only bit 13 cpol: comparator x output polarity select bit 1 = comparator output is inverted 0 = comparator output is not inverted bit 12 clpwr: comparator x low-power mode select bit 1 = comparator operates in low-power mode 0 = comparator does not operate in low-power mode bit 11-10 unimplemented: read as 0 bit 9 cevt: comparator x event bit 1 = comparator event, defined by evpol<1:0>, has occurred; subsequent triggers and interrupts are disabled until the bit is cleared 0 = comparator event has not occurred bit 8 cout: comparator x output bit when cpol = 0 : 1 =v in + > v in - 0 =v in + < v in - when cpol = 1 : 1 =v in + < v in - 0 =v in + > v in - bit 7-6 evpol<1:0>: trigger/event/interrupt polarity select bits ( 2 ) 11 = trigger/event/interrupt is generated on any change of the comparator output (while cevt = 0 ) 10 = trigger/event/interrupt is generated on the high-to-low transition of the comparator output 01 = trigger/event/interrupt is generated on the low-to-high transition of the comparator output 00 = trigger/event/interrupt generation is disabled bit 5 unimplemented: read as 0 bit 4-3 cref<1:0>: comparator x reference select bits (non-inverting input) 11 = non-inverting input connects to the dac2 output 10 = non-inverting input connects to the dac1 output 01 = non-inverting input connects to the internal cv ref voltage 00 = non-inverting input connects to the cxina pin note 1: bgbuf1 voltage is configured by bufref1<1:0> (bufcon0<1:0>). 2: if the evpol<1:0> bits are set to a value other than 00 , the first interrupt generated will occur on any transition of cout. subsequent interrupts will occur based on the evpolx bits setting. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 238 ? 2013 microchip technology inc. bit 2 unimplemented: read as 0 bit 1-0 cch<1:0>: comparator x channel select bits 11 = inverting input of the comparator connects to bgbuf1 ( 1 ) 10 = inverting input of the comparator connects to the cxind pin 01 = inverting input of the comparator connects to the cxinc pin 00 = inverting input of the comparator connects to the cxinb pin register 22-1: cmxcon: comparator x control registers (continued) note 1: bgbuf1 voltage is configured by bufref1<1:0> (bufcon0<1:0>). 2: if the evpol<1:0> bits are set to a value other than 00 , the first interrupt generated will occur on any transition of cout. subsequent interrupts will occur based on the evpolx bits setting. register 22-2: cmstat: comparat or module status register r/w-0 u-0 u-0 u-0 u-0 r-0, hsc r-0, hsc r-0, hsc cmidl c3evt ( 1 ) c2evt ( 1 ) c1evt bit 15 bit 8 u-0 u-0 u-0 u-0 u-0 r-0, hsc r-0, hsc r-0, hsc c 3 o u t ( 1 ) c2out ( 1 ) c1out bit 7 bit 0 legend: hsc = hardware settable/clearable bit r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 cmidl: comparator x stop in idle mode bit 1 = comparator interrupts are disabled in idle mode; enabled comparators remain operational 0 = continues operation of all enabled comparators in idle mode bit 14-11 unimplemented: read as 0 bit 10 c3evt: comparator 3 event status bit (read-only) ( 1 ) shows the current event status of comparator 3 (cm3con<9>). bit 9 c2evt: comparator 2 event status bit (read-only) ( 1 ) shows the current event status of comparator 2 (cm2con<9>). bit 8 c1evt: comparator 1 event status bit (read-only) shows the current event status of comparator 1 (cm1con<9>). bit 7-3 unimplemented: read as 0 bit 2 c3out: comparator 3 output status bit (read-only) ( 1 ) shows the current output of comparator 3 (cm3con<8>). bit 1 c2out: comparator 2 output status bit (read-only) ( 1 ) shows the current output of comparator 2 (cm2con<8>). bit 0 c1out: comparator 1 output status bit (read-only) shows the current output of comparator 1 (cm1con<8>). note 1: comparator 2 and comparator 3 are only available on pic24f(v)16km2xx devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 239 pic24fv16km204 family 23.0 comparator voltage reference 23.1 configuring the comparator voltage reference the comparator voltage reference module is controlled through the cvrcon register ( register 23-1 ). the comparator voltage reference provides a range of output voltages with 32 distinct levels. the comparator voltage reference supply voltage can come from either v dd and v ss , or the external v ref + and v ref -. the voltage source is selected by the cvrss bit (cvrcon<5>). the settling time of the comparator voltage reference must be considered when changing the cv ref output. figure 23-1: comparator volt age reference block diagram note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the comparator voltage reference, refer to the pic24f family reference manual , comparator voltage reference module (ds39709). 32-to-1 mux cvr<3:0> r cvren cvrss = 0 av dd v ref + cvrss = 1 cvrss = 0 v ref - cvrss = 1 rr r r r r 32 steps cv ref av ss downloaded from: http:///
pic24fv16km204 family ds30003030b-page 240 ? 2013 microchip technology inc. register 23-1: cvrcon: comparator vo ltage reference control register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 cvren cvroe cvrss cvr4 cvr3 cvr2 cvr1 cvr0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-8 unimplemented: read as 0 bit 7 cvren: comparator voltage reference enable bit 1 =cv ref circuit is powered on 0 =cv ref circuit is powered down bit 6 cvroe: comparator v ref output enable bit 1 =cv ref voltage level is output on the cv ref pin 0 =cv ref voltage level is disconnected from the cv ref pin bit 5 cvrss: comparator v ref source selection bit 1 = comparator reference source, cv rsrc = v ref + C v ref - 0 = comparator reference source, cv rsrc = av dd C av ss bit 4-0 cvr<4:0>: comparator v ref value selection 0 cvr<4:0> 31 bits when cv rss = 1 : cv ref = (v ref -) + (cvr<4:0>/32) (v ref + C v ref -) when cv rss = 0 : cv ref = (av ss ) + (cvr<4:0>/32) (av dd C av ss ) downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 241 pic24fv16km204 family 24.0 charge time measurement unit (ctmu) the charge time measurement unit (ctmu) is a flexible analog module that provides charge measurement, accurate differential time measurement between pulse sources and asynchronous pulse generation. its key features include: thirteen external edge input trigger sources polarity control for each edge source control of edge sequence control of response to edge levels or edge transitions time measurement resolution of one nanosecond accurate current source suitable for capacitive measurement together with other on-chip analog modules, the ctmu can be used to precisely measure time, measure capacitance, measure relative changes in capacitance or generate output pulses that are independent of the system clock. the ctmu module is ideal for interfacing with capacitive-based touch sensors. the ctmu is controlled through three registers: ctmucon1, ctmucon2 and ctmuicon. ctmucon1 enables the module and controls the mode of operation of the ctmu, as well as controlling edge sequencing. ctmucon2 controls edge source selec- tion and edge source polarity selection. the ctmuicon register selects the current range of current source and trims the current. 24.1 measuring capacitance the ctmu module measures capacitance by generating an output pulse, with a width equal to the time between edge events, on two separate input channels. the pulse edge events to both input channels can be selected from several internal peripheral modules (oc1, timer1, any input capture or comparator module) and up to 13 external pins (cted1 through cted13). this pulse is used with the modules precision current source to calculate capacitance according to the relationship: equation 24-1: for capacitance measurements, the a/d converter samples an external capacitor (c app ) on one of its input channels after the ctmu outputs pulse. a preci- sion resistor (r pr ) provides current source calibration on a second a/d channel. after the pulse ends, the converter determines the voltage on the capacitor. the actual calculation of capacitance is performed in software by the application. figure 24-1 illustrates the external connections used for capacitance measurements, and how the ctmu and a/d modules are related in this application. this example also shows the edge events coming from timer1, but other configurations using external edge sources are possible. a detailed discussion on measur- ing capacitance and time with the ctmu module is provided in the pic24f family reference manual . note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the charge time measurement unit, refer to the pic24f family reference manual , charge time measurement unit (ctmu) with threshold detect (ds39743). ic dv dt ------ - ? = downloaded from: http:///
pic24fv16km204 family ds30003030b-page 242 ? 2013 microchip technology inc. figure 24-1: typical connections and internal configuration for capacitance measurement 24.2 measuring time time measurements on the pulse width can be similarly performed using the a/d modules internal capacitor (c ad ) and a precision resistor for current calibration. figure 24-2 displays the external connections used for time measurements, and how the ctmu and a/d modules are related in this application. this example also shows both edge events coming from the external ctedx pins, but other configurations using internal edge sources are possible. figure 24-2: typical connections and internal configuration for time measurement pic24f device a/d converter ctmu anx c app output pulse edg1stat edg2stat r pr any timer1 current source pic24f device a/d converter ctmu cted x cted x anx output pulse edg1stat edg2stat c ad r pr current source downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 243 pic24fv16km204 family 24.3 pulse generation and delay the ctmu module can also generate an output pulse with edges that are not synchronous with the devices system clock. more specifically, it can generate a pulse with a programmable delay from an edge event input to the module. when the module is configured for pulse generation delay by setting the tgen bit (ctmucon1l<12>), the internal current source is connected to the b input of comparator 2. a capacitor (c delay ) is connected to the comparator 2 pin, c2inb, and the comparator voltage reference, cv ref , is connected to c2ina. cv ref is then configured for a specific trip point. the module begins to charge c delay when an edge event is detected. while cv ref is greater than the voltage on c delay , the ctpls pin is high. when the voltage on c delay equals cv ref , ctpls goes low. with comparator 2 configured as the second edge, this stops the ctmu from charging. in this state event, the ctmu automatically connects to ground. the idissen bit doesnt need to be set and cleared before the next ctpls cycle. figure 24-3 illustrates the external connections for pulse generation, as well as the relationship of the different analog modules required. while cted1 is shown as the input pulse source, other options are available. a detailed discussion on pulse generation with the ctmu module is provided in the pic24f family reference manual . figure 24-3: typical co nnections and internal co nfiguration for pulse delay generation c2 cv ref ctpls pic24f device current comparator ctmu cted1 c2inb c delay edg1stat C q q dck edg2stat source r v dd edg1stat edg2stat downloaded from: http:///
pic24fv16km204 family ds30003030b-page 244 ? 2013 microchip technology inc. register 24-1: ctmucon1l: ct mu control 1 low register r/w-0 u-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 ctmuen ctmusidl tgen edgen edgseqen idissen cttrig bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 itrim5 itrim4 itrim3 itrim2 itrim1 itrim0 irng1 irng0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 ctmuen: ctmu enable bit 1 = module is enabled 0 = module is disabled bit 14 unimplemented: read as 0 bit 13 ctmusidl: ctmu stop in idle mode bit 1 = discontinues module operation when device enters idle mode 0 = continues module operation in idle mode bit 12 tgen: time generation enable bit 1 = enables edge delay generation 0 = disables edge delay generation bit 11 edgen: edge enable bit 1 = edges are not blocked 0 = edges are blocked bit 10 edgseqen: edge sequence enable bit 1 = edge 1 event must occur before edge 2 event can occur 0 = no edge sequence is needed bit 9 idissen: analog current source control bit 1 = analog current source output is grounded 0 = analog current source output is not grounded bit 8 cttrig: ctmu trigger control bit 1 = trigger output is enabled 0 = trigger output is disabled bit 7-2 itrim<5:0>: current source trim bits 011111 = maximum positive change from nominal current 011110 000001 = minimum positive change from nominal current 000000 = nominal current output specified by irng<1:0> 111111 = minimum negative change from nominal current 100010 100001 = maximum negative change from nominal current downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 245 pic24fv16km204 family bit 1-0 irng<1:0>: current source range select bits 11 = 100 base current 10 = 10 base current 01 = base current level (0.55 a nominal) 00 = 1000 base current register 24-1: ctmucon1l: ctmu co ntrol 1 low register (continued) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 246 ? 2013 microchip technology inc. register 24-2: ctmucon1h: ctmu control 1 high register r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 edg1mod edg1pol edg1sel3 edg1sel2 e dg1sel1 edg1sel0 edg2stat edg1stat bit 15 bit 8 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 r/w-0 u-0 u-0 edg2mod edg2pol edg2sel3 edg2sel2 edg2sel1 edg2sel0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15 edg1mod: edge 1 edge-sensitive select bit 1 = input is edge-sensitive 0 = input is level-sensitive bit 14 edg1pol: edge 1 polarity select bit 1 = edge 1 is programmed for a positive edge response 0 = edge 1 is programmed for a negative edge response bit 13-10 edg1sel<3:0>: edge 1 source select bits 1111 = edge 1 source is the comparator 3 output 1110 = edge 1 source is the comparator 2 output 1101 = edge 1 source is the comparator 1 output 1100 = edge 1 source is clc2 1011 = edge 1 source is clc1 1010 = edge 1 source is the mccp2 compare event (ccp2if) 1001 = edge 1 source is cted8 ( 1 ) 1000 = edge 1 source is cted7 ( 1 ) 0111 = edge 1 source is cted6 0110 = edge 1 source is cted5 0101 = edge 1 source is cted4 0100 = edge 1 source is cted3 ( 2 ) 0011 = edge 1 source is cted1 0010 = edge 1 source is cted2 0001 = edge 1 source is the mccp1 compare event (ccp1if) 0000 = edge 1 source is timer1 bit 9 edg2stat: edge 2 status bit indicates the status of edge 2 and can be written to control the current source. 1 = edge 2 has occurred 0 = edge 2 has not occurred bit 8 edg1stat: edge 1 status bit indicates the status of edge 1 and can be written to control the current source. 1 = edge 1 has occurred 0 = edge 1 has not occurred bit 7 edg2mod: edge 2 edge-sensitive select bit 1 = input is edge-sensitive 0 = input is level-sensitive note 1: edge sources, cted7 and cted8, are not available on 28-pin and 20-pin devices. 2: edge sources, cted3, cted9 and cted11, are not available on 20-pin devices. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 247 pic24fv16km204 family bit 6 edg2pol: edge 2 polarity select bit 1 = edge 2 is programmed for a positive edge 0 = edge 2 is programmed for a negative edge bit 5-2 edg2sel<3:0>: edge 2 source select bits 1111 = edge 2 source is the comparator 3 output 1110 = edge 2 source is the comparator 2 output 1101 = edge 2 source is the comparator 1 output 1100 = unimplemented; do not use 1011 = edge 2 source is clc1 1010 = edge 2 source is the mccp2 compare event (ccp2if) 1001 = unimplemented; do not use 1000 = edge 2 source is cted13 0111 = edge 2 source is cted12 0110 = edge 2 source is cted11 ( 2 ) 0101 = edge 2 source is cted10 0100 = edge 2 source is cted9 ( 2 ) 0011 = edge 2 source is cted1 0010 = edge 2 source is cted2 0001 = edge 2 source is the mccp1 compare event (ccp1if) 0000 = edge 2 source is timer1 bit 1-0 unimplemented: read as 0 register 24-2: ctmucon1h: ctmu control 1 high register (continued) note 1: edge sources, cted7 and cted8, are not available on 28-pin and 20-pin devices. 2: edge sources, cted3, cted9 and cted11, are not available on 20-pin devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 248 ? 2013 microchip technology inc. register 24-3: ctmucon2l: ct mu control 2 low register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 r/w-0 u-0 r/w-0 r/w-0 r/w-0 i r s t e n dischs2 dischs1 dischs0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 15-5 unimplemented: read as 0 bit 4 irsten: ctmu current source reset enable bit 1 = signal selected by the dischs<2:0> bits or the idissen control bit will reset the ctmu edge detect logic 0 = ctmu edge detect logic will not occur bit 3 unimplemented: read as 0 bit 2-0 dischs<2:0>: discharge source select bits 111 = clc2 output 110 = clc1 output 101 = reserved; do not use. 100 = a/d end of conversion signal 011 = sccp5 auxiliary output 110 = mccp2 auxiliary output 001 = mccp1 auxiliary output 000 = no discharge source selected, use the idissen bit downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 249 pic24fv16km204 family 25.0 special features pic24fxxxxx family devices include several features intended to maximize application flexibility and reli- ability, and minimize cost through elimination of external components. these are: flexible configuration watchdog timer (wdt) code protection in-circuit serial programming? (icsp?) in-circuit emulation 25.1 configuration bits the configuration bits can be programmed (read as 0 ) or left unprogrammed (read as 1 ) to select various device configurations. these bits are mapped, starting at program memory location, f80000h. a complete list of configuration register locations is provided in table 25-1 . a detailed explanation of the various bit functions is provided in register 25-1 through register 25-9 . the address, f80000h, is beyond the user program memory space. in fact, it belongs to the configuration memory space (800000h-ffffffh), which can only be accessed using table reads and table writes. table 25-1: configuration registers locations register 25-1: fbs: boot se gment configuration register note: this data sheet summarizes the features of this group of pic24f devices. it is not intended to be a comprehensive reference source. for more information on the watchdog timer, high-level device integration and programming diagnostics, refer to the individual sections of the pic24f family reference manual provided below: watchdog timer (wdt) (ds39697) programming and diagnostics (ds39716) configuration register address fbs f80000 fgs f80004 foscsel f80006 fosc f80008 fwdt f8000a fpor f8000c ficd f8000e u-0 u-0 u-0 u-0 r/w-1 r/w-1 r/w-1 r/w-1 bss2 bss1 bss0 bwrp bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-4 unimplemented: read as 0 bit 3-1 bss<2:0>: boot segment program flash code protection bits 111 = no boot program flash segment 011 = reserved 110 = standard security, boot program flash segment starts at 200h, ends at 000afeh 010 = high-security, boot program flash segment starts at 200h, ends at 000afeh 101 = standard security, boot program flash segment starts at 200h, ends at 0015feh ( 1 ) 001 = high-security, boot program flash segment starts at 200h, ends at 0015feh ( 1 ) 100 = reserved 000 = reserved bit 0 bwrp: boot segment program flash write protection bit 1 = boot segment may be written 0 = boot segment is write-protected note 1: this selection should not be used in pic24fv08kmxxx devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 250 ? 2013 microchip technology inc. register 25-2: fgs: general se gment configuration register register 25-3: foscsel: oscillator selection configuration register u-0 u-0 u-0 u-0 u-0 u-0 r/c-1 r/c-1 gcp gwrp bit 7 bit 0 legend: r = readable bit c = clearable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-2 unimplemented: read as 0 bit 1 gcp: general segment code flash code protection bit 1 = no protection 0 = standard security is enabled bit 0 gwrp: general segment code flash write protection bit 1 = general segment may be written 0 = general segment is write-protected r/p-1 r/p-1 r/p-1 u-0 u-0 r/p-1 r/p-1 r/p-1 ieso lprcsel soscsrc fnosc2 fnosc1 fnosc0 bit 7 bit 0 legend: r = readable bit p = programmable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 ieso: internal external switchover bit 1 = internal external switchover mode is enabled (two-speed start-up is enabled) 0 = internal external switchover mode is disabled (two-speed start-up is disabled) bit 6 lprcsel: internal lprc oscillator power select bit 1 = high-power/high-accuracy mode 0 = low-power/low-accuracy mode bit 5 soscsrc: secondary oscillator clock source configuration bit 1 = sosc analog crystal function is available on the sosci/sosco pins 0 = sosc crystal is disabled; digital sclki function is selected on the sosco pin bit 4-3 unimplemented: read as 0 bit 2-0 fnosc<2:0>: oscillator selection bits 000 = fast rc oscillator (frc) 001 = fast rc oscillator with divide-by-n with pll module (frcdiv+pll) 010 = primary oscillator (xt, hs, ec) 011 = primary oscillator with pll module (hs+pll, ec+pll) 100 = secondary oscillator (sosc) 101 = low-power rc oscillator (lprc) 110 = 500 khz low-power frc oscillator with divide-by-n (lpfrcdiv) 111 = 8 mhz frc oscillator with divide-by-n (frcdiv) downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 251 pic24fv16km204 family register 25-4: fosc: oscilla tor configuration register r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 fcksm1 fcksm0 soscsel poscfreq1 poscfreq0 osciofnc poscmd1 poscmd0 bit 7 bit 0 legend: r = readable bit p = programmable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7-6 fcksm<1:0>: clock switching and fail-safe clock monitor selection configuration bits 1x = clock switching is disabled, fail-safe clock monitor is disabled 01 = clock switching is enabled, fail-safe clock monitor is disabled 00 = clock switching is enabled, fail-safe clock monitor is enabled bit 5 soscsel: secondary oscillator power selection configuration bit 1 = secondary oscillator is configured for high-power operation 0 = secondary oscillator is configured for low-power operation bit 4-3 poscfreq<1:0>: primary oscillator frequency range configuration bits 11 = primary oscillator/external clock input frequency is greater than 8 mhz 10 = primary oscillator/external clock input frequency is between 100 khz and 8 mhz 01 = primary oscillator/external clock input frequency is less than 100 khz 00 = reserved; do not use bit 2 osciofnc: clko enable configuration bit 1 = clko output signal is active on the osco pin; primary oscillator must be disabled or configured for the external clock (ec) mode for the clko to be active (poscmd<1:0> = 11 or 00 ) 0 = clko output is disabled bit 1-0 poscmd<1:0>: primary oscillator configuration bits 11 = primary oscillator mode is disabled 10 = hs oscillator mode is selected 01 = xt oscillator mode is selected 00 = external clock mode is selected downloaded from: http:///
pic24fv16km204 family ds30003030b-page 252 ? 2013 microchip technology inc. register 25-5: fwdt: watchdog timer configuration register r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 fwdten1 windis fwdten0 fwpsa wdtps3 wdtps2 wdtps1 wdtps0 bit 7 bit 0 legend: r = readable bit p = programmable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7,5 fwdten<1:0>: watchdog timer enable bits 11 = wdt is enabled in hardware 10 = wdt is controlled with the swdten bit setting 01 = wdt is enabled only while the device is active, wdt is disabled in sleep; swdten bit is disabled 00 = wdt is disabled in hardware; swdten bit is disabled bit 6 windis: windowed watchdog timer disable bit 1 = standard wdt is selected; windowed wdt is disabled 0 = windowed wdt is enabled; note that executing a clrwdt instruction while the wdt is disabled in hardware and software (fwdten<1:0> = 00 and swdten (rcon<5>) = 0 ) will not cause a device reset bit 4 fwpsa: wdt prescaler bit 1 = wdt prescaler ratio of 1:128 0 = wdt prescaler ratio of 1:32 bit 3-0 wdtps<3:0>: watchdog timer postscale select bits 1111 = 1:32,768 1110 = 1:16,384 1101 = 1:8,192 1100 = 1:4,096 1011 = 1:2,048 1010 = 1:1,024 1001 = 1:512 1000 = 1:256 0111 = 1:128 0110 = 1:64 0101 = 1:32 0100 = 1:16 0011 = 1:8 0010 = 1:4 0001 = 1:2 0000 = 1:1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 253 pic24fv16km204 family register 25-6: fpor: rese t configuration register r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 r/p-1 mclre ( 2 ) borv1 ( 3 ) borv0 ( 3 ) i2c1sel ( 1 ) pwrten retcfg ( 1 ) boren1 boren0 bit 7 bit 0 legend: r = readable bit p = programmable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 mclre: mclr pin enable bit ( 2 ) 1 = mclr pin is enabled; ra5 input pin is disabled 0 = ra5 input pin is enabled; mclr is disabled bit 6-5 borv<1:0>: brown-out reset enable bits ( 3 ) 11 = brown-out reset is set to the lowest voltage 10 = brown-out reset is set to the middle voltage 01 = brown-out reset is set to the highest voltage 00 = downside protection on por is enabled C low-power bor (lpbor) is selected bit 4 i2c1sel: alternate i2c1 pin mapping bit ( 1 ) 1 = default location for scl1/sda1 pins 0 = alternate location for scl1/sda1 pins bit 3 pwrten: power-up timer enable bit 1 = pwrt is enabled 0 = pwrt is disabled bit 2 retcfg: retention regulator configuration bit ( 1 ) 1 = low-voltage regulator is not available 0 = low-voltage regulator is available and controlled by the reten bit (rcon<12>) during sleep bit 1-0 boren<1:0>: brown-out reset enable bits 11 = brown-out reset is enabled in hardware; sboren bit is disabled 10 = brown-out reset is enabled only while device is active and disabled in sleep; sboren bit is disabled 01 = brown-out reset is controlled with the sboren bit setting 00 = brown-out reset is disabled in hardware; sboren bit is disabled note 1: this setting only applies to the fv devices. this bit is reserved and should be maintained as 1 on f devices. 2: the mclre fuse can only be changed when using the v pp -based icsp? mode entry. this prevents a user from accidentally locking out the device from the low-voltage test entry. 3: refer to section 27.0 electrical characteristics for bor voltages. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 254 ? 2013 microchip technology inc. register 25-7: ficd: in-circuit debugger configuration register r/p-1 u-0 u-0 u-0 u-0 u-0 r/p-1 r/p-1 debug ficd1 ficd0 bit 7 bit 0 legend: r = readable bit p = programmable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 7 debug : background debugger enable bit 1 = background debugger is disabled 0 = background debugger functions are enabled bit 6-2 unimplemented: read as 0 bit 1-0 ficd<1:0:>: icd pin select bits 11 = pgec1/pged1 are used for programming and debugging the device 10 = pgec2/pged2 are used for programming and debugging the device 01 = pgec3/pged3 are used for programming and debugging the device 00 = reserved; do not use downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 255 pic24fv16km204 family register 25-8: devid: device id register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 23 bit 16 rrrrrrrr famid7 famid6 famid5 famid4 famid3 famid2 famid1 famid0 bit 15 bit 8 rrrrrrrr dev7 dev6 dev5 dev4 dev3 dev2 dev1 dev0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 23-16 unimplemented: read as 0 bit 15-8 famid<7:0>: device family identifier bits 01000101 = pic24fv16km204 family bit 7-0 dev<7:0>: individual device identifier bits 00011111 = pic24fv16km204 00011011 = pic24fv16km202 00010111 = pic24fv08km204 00010011 = pic24fv08km202 00001111 = pic24fv16km104 00001011 = pic24fv16km102 00000011 = pic24fv08km102 00000001 = pic24fv08km101 00011110 = pic24f16km204 00011010 = pic24f16km202 00010110 = pic24f08km204 00010010 = pic24f08km202 00001110 = pic24f16km104 00001010 = pic24f16km102 00000010 = pic24f08km102 00000000 = pic24f08km101 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 256 ? 2013 microchip technology inc. register 25-9: devrev: device revision register u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 23 bit 16 u-0 u-0 u-0 u-0 u-0 u-0 u-0 u-0 bit 15 bit 8 u-0 u-0 u-0 u-0 r r r r rev3 rev2 rev1 rev0 bit 7 bit 0 legend: r = readable bit w = writable bit u = unimplemented bit, read as 0 -n = value at por 1 = bit is set 0 = bit is cleared x = bit is unknown bit 23-4 unimplemented: read as 0 bit 3-0 rev<3:0>: minor revision identifier bits downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 257 pic24fv16km204 family 25.2 on-chip voltage regulator all of the pic24fxxxxx family devices power their core digital logic at a nominal 3.0v. this may create an issue for designs that are required to operate at a higher typical voltage, as high as 5.0v. to simplify sys- tem design, all devices in the fv family incorporate an on-chip regulator that allows the device core to run at 3.0v, while the i/o is powered by v dd at a higher voltage. the regulator is always enabled and provides power to the core from the other v dd pins. a low-esr capacitor (such as ceramic) must be connected to the v cap pin ( figure 25-1 ). this helps to maintain the stability of the regulator. the recommended value for the filter capac- itor is provided in section 27.1 dc characteristics and discussed in detail in section 2.0 guidelines for getting started with 16-bit microcontrollers . in all of the f family of devices, the regulator is disabled. instead, the core logic is directly powered from v dd . f devices operate at a lower range of v dd voltage, from 1.8v-3.6v. 25.2.1 voltage regulator tracking mode and low-voltage detection for all pic24fxxxxx devices, the on-chip regulator provides a constant voltage of 3.0v nominal to the dig- ital core logic. the regulator can provide this level from a v dd of about 3.2v, all the way up to the devices v ddmax . it does not have the capability to boost v dd levels below 3.2v. in order to prevent brown out con- ditions when the voltage drops too low for the regulator, the regulator enters tracking mode. in tracking mode, the regulator output follows v dd with a typical voltage drop of 150 mv. when the device enters tracking mode, it is no longer possible to operate at full speed. to provide information about when the device enters tracking mode, the on-chip high/low-voltage detect (hlvd) module can be used. the hlvd trip point should be configured so that if v dd drops close to the minimum voltage for the oper- ating frequency of the device, the hlvd interrupt flag, hlvdif (ifs4<8>), will occur. this can be used to generate an interrupt and put the application into a low-power operational mode or trigger an orderly shutdown. refer to section 27.1 dc characteristics for the specifications detailing the maximum operating speed based on the applied v dd voltage. figure 25-1: conne ctions for the on-chip voltage regulator 25.2.2 voltage regulator start-up time for pic24fxxxxx family devices, it takes a short time, designated as t pm , for the regulator to generate a stable output. during this time, code execution is dis- abled. t pm is applied every time the device resumes operation after any power-down, including sleep mode. t pm is specified in section 27.2 ac characteristics and timing parameters . 25.3 watchdog timer (wdt) for the pic24fxxxxx family of devices, the wdt is driven by the lprc oscillator. when the wdt is enabled, the clock source is also enabled. the nominal wdt clock source from lprc is 31 khz. this feeds a prescaler that can be configured for either 5-bit (divide-by-32) or 7-bit (divide-by-128) operation. the prescaler is set by the fwpsa configuration bit. with a 31 khz input, the prescaler yields a nominal wdt time-out period (t wdt ) of 1 ms in 5-bit mode or 4 ms in 7-bit mode. a variable postscaler divides down the wdt prescaler output and allows for a wide range of time-out periods. the postscaler is controlled by the configuration bits, wdtps<3:0> (fwdt<3:0>), which allow the selection of a total of 16 settings, from 1:1 to 1:32,768. using the prescaler and postscaler time-out periods, ranges from 1 ms to 131 seconds can be achieved. v dd v cap v ss pic24fv16km c efc 5.0v (10 ? f typ) regulator enabled: (1) note 1: these are typical operating voltages. refer to section 27.0 electrical characteristics for the full operating ranges of v dd and v ddcore . downloaded from: http:///
pic24fv16km204 family ds30003030b-page 258 ? 2013 microchip technology inc. the wdt, prescaler and postscaler are reset: on any device reset on the completion of a clock switch, whether invoked by software (i.e., setting the oswen bit after changing the noscx bits) or by hardware (i.e., fail-safe clock monitor) when a pwrsav instruction is executed (i.e., sleep or idle mode is entered) when the device exits sleep or idle mode to resume normal operation by a clrwdt instruction during normal execution if the wdt is enabled in hardware (fwdten<1:0> = 11 ), it will continue to run during sleep or idle modes. when the wdt time-out occurs, the device will wake and code execution will continue from where the pwrsav instruction was executed. the corresponding sleep or idle bit (rcon<3:2>) will need to be cleared in software after the device wakes up. the wdt flag bit, wdto (rcon<4>), is not auto- matically cleared following a wdt time-out. to detect subsequent wdt events, the flag must be cleared in software. 25.3.1 windowed operation the watchdog timer has an optional fixed window mode of operation. in this windowed mode, clrwdt instructions can only reset the wdt during the last 1/4 of the programmed wdt period. a clrwdt instruction executed before that window causes a wdt reset, similar to a wdt time-out. windowed wdt mode is enabled by programming the configuration bit, windis (fwdt<6>), to 0 . 25.3.2 control register the wdt is enabled or disabled by the fwdten<1:0> configuration bits. when both of the fwdten<1:0> configuration bits are set, the wdt is always enabled. the wdt can be optionally controlled in software when the fwdten<1:0> configuration bits have been pro- grammed to 10 . the wdt is enabled in software by setting the swdten control bit (rcon<5>). the swdten control bit is cleared on any device reset. the software wdt option allows the user to enable the wdt for critical code segments, and disable the wdt during non-critical segments, for maximum power savings. when the fwdten<1:0> bits are set to 01 , the wdt is only enabled in run and idle modes, and is disabled in sleep. software control of the swdten bit (rcon<5>) is disabled with this setting. figure 25-2: wdt block diagram note: the clrwdt and pwrsav instructions clear the prescaler and postscaler counts when executed. lprc input wdt overflow wake from sleep 31 khz prescaler postscaler fwpsa swdten fwdten<1:0> reset all device resets sleep or idle mode lprc control clrwdt instr. pwrsav instr. (5-bit/7-bit) 1:1 to 1:32.768 wdtps<3:0> 1 ms/4 ms exit sleep or idle mode wdt counter transition to new clock source downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 259 pic24fv16km204 family 25.4 program verification and code protection for all devices in the pic24fxxxxx family, code protection for the boot segment is controlled by the configuration bit, bss0, and the general segment by the configuration bit, gcp. these bits inhibit external reads and writes to the program memory space this has no direct effect in normal execution mode. write protection is controlled by bit, bwrp, for the boot segment and bit, gwrp, for the general segment in the configuration word. when these bits are pro- grammed to 0 , internal write and erase operations to program memory are blocked. 25.5 in-circuit serial programming pic24fxxxxx family microcontrollers can be serially programmed while in the end application circuit. this is simply done with two lines for clock (pgecx) and data (pgedx), and three other lines for power, ground and the programming voltage. this allows customers to manufacture boards with unprogrammed devices and then program the microcontroller just before shipping the product. this also allows the most recent firmware or a custom firmware to be programmed. 25.6 in-circuit debugger when mplab ? icd 3, mplab real ice? or pickit? 3 is selected as a debugger, the in-circuit debugging functionality is enabled. this function allows simple debugging functions when used with mplab ide. debugging functionality is controlled through the pgecx and pgedx pins. to use the in-circuit debugger function of the device, the design must implement icsp connections to mclr , v dd , v ss , pgecx, pgedx and the pin pair. in addition, when the feature is enabled, some of the resources are not available for general use. these resources include the first 80 bytes of data ram and two i/o pins. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 260 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 261 pic24fv16km204 family 26.0 development support the pic ? microcontrollers (mcu) and dspic ? digital signal controllers (dsc) are supported with a full range of software and hardware development tools: integrated development environment - mplab ? x ide software compilers/assemblers/linkers - mplab xc compiler - mpasm tm assembler -mplink tm object linker/ mplib tm object librarian - mplab assembler/linker/librarian for various device families simulators - mplab x sim software simulator emulators - mplab real ice? in-circuit emulator in-circuit debuggers/programmers - mplab icd 3 - pickit? 3 device programmers - mplab pm3 device programmer low-cost demonstration/development boards, evaluation kits and starter kits third-party development tools 26.1 mplab x integrated development environment software the mplab x ide is a single, unified graphical user interface for microchip and third-party software, and hardware development tool that runs on windows ? , linux and mac os ? x. based on the netbeans ide, mplab x ide is an entirely new ide with a host of free software components and plug-ins for high- performance application development and debugging. moving between tools and upgrading from software simulators to hardware debugging and programming tools is simple with the seamless user interface. with complete project management, visual call graphs, a configurable watch window and a feature-rich editor that includes code completion and context menus, mplab x ide is flexible and friendly enough for new users. with the ability to support multiple tools on multiple projects with simultaneous debugging, mplab x ide is also suitable for the needs of experienced users. feature-rich editor: color syntax highlighting smart code completion makes suggestions and provides hints as you type automatic code formatting based on user-defined rules live parsing user-friendly, customizable interface: fully customizable interface: toolbars, toolbar buttons, windows, window placement, etc. call graph window project-based workspaces: multiple projects multiple tools multiple configurations simultaneous debugging sessions file history and bug tracking: local file history feature built-in support for bugzilla issue tracker downloaded from: http:///
pic24fv16km204 family ds30003030b-page 262 ? 2013 microchip technology inc. 26.2 mplab xc compilers the mplab xc compilers are complete ansi c compilers for all of microchips 8, 16 and 32-bit mcu and dsc devices. these compilers provide powerful integration capabilities, superior code optimization and ease of use. mplab xc compilers run on windows, linux or mac os x. for easy source level debugging, the compilers provide debug information that is optimized to the mplab x ide. the free mplab xc compiler editions support all devices and commands, with no time or memory restrictions, and offer sufficient code optimization for most applications. mplab xc compilers include an assembler, linker and utilities. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an exe- cutable file. mplab xc compiler uses the assembler to produce its object file. notable features of the assembler include: support for the entire device instruction set support for fixed-point and floating-point data command-line interface rich directive set flexible macro language mplab x ide compatibility 26.3 mpasm assembler the mpasm assembler is a full-featured, universal macro assembler for pic10/12/16/18 mcus. the mpasm assembler generates relocatable object files for the mplink object linker, intel ? standard hex files, map files to detail memory usage and symbol reference, absolute lst files that contain source lines and generated machine code, and coff files for debugging. the mpasm assembler features include: integration into mplab x ide projects user-defined macros to streamline assembly code conditional assembly for multipurpose source files directives that allow complete control over the assembly process 26.4 mplink object linker/ mplib object librarian the mplink object linker combines relocatable objects created by the mpasm assembler. it can link relocatable objects from precompiled libraries, using directives from a linker script. the mplib object librarian manages the creation and modification of library files of precompiled code. when a routine from a library is called from a source file, only the modules that contain that routine will be linked in with the application. this allows large libraries to be used efficiently in many different applications. the object linker/library features include: efficient linking of single libraries instead of many smaller files enhanced code maintainability by grouping related modules together flexible creation of libraries with easy module listing, replacement, deletion and extraction 26.5 mplab assembler, linker and librarian for various device families mplab assembler produces relocatable machine code from symbolic assembly language for pic24, pic32 and dspic dsc devices. mplab xc compiler uses the assembler to produce its object file. the assembler generates relocatable object files that can then be archived or linked with other relocatable object files and archives to create an executable file. notable features of the assembler include: support for the entire device instruction set support for fixed-point and floating-point data command-line interface rich directive set flexible macro language mplab x ide compatibility downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 263 pic24fv16km204 family 26.6 mplab x sim software simulator the mplab x sim software simulator allows code development in a pc-hosted environment by simulat- ing the pic mcus and dspic dscs on an instruction level. on any given instruction, the data areas can be examined or modified and stimuli can be applied from a comprehensive stimulus controller. registers can be logged to files for further run-time analysis. the trace buffer and logic analyzer display extend the power of the simulator to record and track program execution, actions on i/o, most peripherals and internal registers. the mplab x sim software simulator fully supports symbolic debugging using the mplab xc compilers, and the mpasm and mplab assemblers. the soft- ware simulator offers the flexibility to develop and debug code outside of the hardware laboratory envi- ronment, making it an excellent, economical software development tool. 26.7 mplab real ice in-circuit emulator system the mplab real ice in-circuit emulator system is microchips next generation high-speed emulator for microchip flash dsc and mcu devices. it debugs and programs all 8, 16 and 32-bit mcu, and dsc devices with the easy-to-use, powerful graphical user interface of the mplab x ide. the emulator is connected to the design engineers pc using a high-speed usb 2.0 interface and is connected to the target with either a connector compatible with in-circuit debugger systems (rj-11) or with the new high-speed, noise tolerant, low- voltage differential signal (lvds) interconnection (cat5). the emulator is field upgradable through future firmware downloads in mplab x ide. mplab real ice offers significant advantages over competitive emulators including full-speed emulation, run-time variable watches, trace analysis, complex breakpoints, logic probes, a ruggedized probe interface and long (up to three meters) interconnection cables. 26.8 mplab icd 3 in-circuit debugger system the mplab icd 3 in-circuit debugger system is microchips most cost-effective, high-speed hardware debugger/programmer for microchip flash dsc and mcu devices. it debugs and programs pic flash microcontrollers and dspic dscs with the powerful, yet easy-to-use graphical user interface of the mplab ide. the mplab icd 3 in-circuit debugger probe is connected to the design engineers pc using a high- speed usb 2.0 interface and is connected to the target with a connector compatible with the mplab icd 2 or mplab real ice systems (rj-11). mplab icd 3 supports all mplab icd 2 headers. 26.9 pickit 3 in-circuit debugger/ programmer the mplab pickit 3 allows debugging and program- ming of pic and dspic flash microcontrollers at a most affordable price point using the powerful graphical user interface of the mplab ide. the mplab pickit 3 is connected to the design engineers pc using a full- speed usb interface and can be connected to the target via a microchip debug (rj-11) connector (com- patible with mplab icd 3 and mplab real ice). the connector uses two device i/o pins and the reset line to implement in-circuit debugging and in-circuit serial programming? (icsp?). 26.10 mplab pm3 device programmer the mplab pm3 device programmer is a universal, ce compliant device programmer with programmable voltage verification at v ddmin and v ddmax for maximum reliability. it features a large lcd display (128 x 64) for menus and error messages, and a mod- ular, detachable socket assembly to support various package types. the icsp cable assembly is included as a standard item. in stand-alone mode, the mplab pm3 device programmer can read, verify and program pic devices without a pc connection. it can also set code protection in this mode. the mplab pm3 connects to the host pc via an rs-232 or usb cable. the mplab pm3 has high-speed communications and optimized algorithms for quick programming of large memory devices, and incorporates an mmc card for file storage and data applications. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 264 ? 2013 microchip technology inc. 26.11 demonstration/development boards, evaluation kits and starter kits a wide variety of demonstration, development and evaluation boards for various pic mcus and dspic dscs allows quick application development on fully functional systems. most boards include prototyping areas for adding custom circuitry and provide applica- tion firmware and source code for examination and modification. the boards support a variety of features, including leds, temperature sensors, switches, speakers, rs-232 interfaces, lcd displays, potentiometers and additional eeprom memory. the demonstration and development boards can be used in teaching environments, for prototyping custom circuits and for learning about various microcontroller applications. in addition to the picdem? and dspicdem? demonstration/development board series of circuits, microchip has a line of evaluation kits and demonstra- tion software for analog filter design, k ee l oq ? security ics, can, irda ? , powersmart battery management, seeval ? evaluation system, sigma-delta adc, flow rate sensing, plus many more. also available are starter kits that contain everything needed to experience the specified device. this usually includes a single application and debug capability, all on one board. check the microchip web page ( www.microchip.com ) for the complete list of demonstration, development and evaluation kits. 26.12 third-party development tools microchip also offers a great collection of tools from third-party vendors. these tools are carefully selected to offer good value and unique functionality. device programmers and gang programmers from companies, such as softlog and ccs software tools from companies, such as gimpel and trace systems protocol analyzers from companies, such as saleae and total phase demonstration boards from companies, such as mikroelektronika, digilent ? and olimex embedded ethernet solutions from companies, such as ez web lynx, wiznet and iplogika ? downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 265 pic24fv16km204 family 27.0 electrical characteristics this section provides an overview of the pic24fv16km204 family electrical characteristics. additional information will be provided in future revisions of this document as it becomes available. absolute maximum ratings for the pic24fv16km204 family are listed below. exposure to these maximum rating conditions for extended periods may affect device reliability. functional operation of the device at these, or any other conditions above the parameters indicated in the operation listings of this specification, is not implied. absolute maximum ratings ( ? ) ambient temperature under bias................................................................................................. ............-40c to +125c storage temperature ............................................................................................................ .................. -65c to +150c voltage on v dd with respect to v ss (pic24fxxkmxxx) ........................................................................ -0.3v to +4.5v voltage on v dd with respect to v ss (pic24fvxxkmxxx) ...................................................................... -0.3v to +6.5v voltage on any combined analog and digital pin with respect to v ss ............................................ -0.3v to (v dd + 0.3v) voltage on any digital only pin with respect to v ss ....................................................................... -0.3v to (v dd + 0.3v) voltage on mclr /v pp pin with respect to v ss ......................................................................................... -0.3v to +9.0v maximum current out of v ss pin ........................................................................................................................... 300 ma maximum current into v dd pin ( 1 ) ...........................................................................................................................250 ma maximum output current sunk by any i/o pin..................................................................................... .....................25 ma maximum output current sourced by any i/o pin .................................................................................. ..................25 ma maximum current sunk by all ports .......................................................................................................................200 ma maximum current sourced by all ports ( 1 ) ...............................................................................................................200 ma note 1: maximum allowable current is a function of device maximum power dissipation (see tab l e 2 7- 1 ). ? notice: stresses above those listed under absolute maximum ratings may cause permanent damage to the device. this is a stress rating only and functional operation of the device at those or any other conditions above those indicated in the operation listings of this specification is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 266 ? 2013 microchip technology inc. 27.1 dc characteristics figure 27-1: pic24fv16km204 family voltage-frequency graph (industrial) figure 27-2: pic24f16km204 family vo ltage-frequency graph (industrial) frequency voltage (v dd ) 2.00v 32 mhz 5.5v 3.20v 5.5v 8 mhz 3.20v note: for frequencies between 8 mhz and 32 mhz, f max = 20 mhz * (v dd C 2.0) + 8 mhz. frequency voltage (v dd ) 1.80v 32 mhz 3.60v 3.00v 3.60v 8 mhz 3.00v note: for frequencies between 8 mhz and 32 mhz, f max = 20 mhz * (v dd C 1.8) + 8 mhz. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 267 pic24fv16km204 family figure 27-3: pic24fv16km204 family voltage-frequency graph (extended) figure 27-4: pic24f16km204 family voltage-frequency graph (extended) frequency voltage (v dd ) 2.00v 24 mhz 5.5v 3.20v 5.5v 8 mhz 3.20v note: for frequencies between 8 mhz and 24 mhz, f max = 13.33 mhz * (v dd C 2.0) + 8 mhz. frequency voltage (v dd ) 1.80v 24 mhz 3.60v 3.00v 3.60v 8 mhz 3.00v note: for frequencies between 8 mhz and 24 mhz, f max = 13.33 mhz * (v dd C 1.8) + 8 mhz. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 268 ? 2013 microchip technology inc. table 27-1: thermal operating conditions rating symbol min typ max unit operating junction temperature range t j -40 +140 c operating ambient temperature range t a -40 +125 c power dissipation internal chip power dissipation: p int = v dd x (i dd ? ? i oh ) p d p int + p i / o w i/o pin power dissipation: p i / o = ? ({v dd ? v oh } x i oh ) + ? (v ol x i ol ) maximum allowed power dissipation p dmax (t j C t a )/ ? ja w table 27-2: thermal packaging characteristics characteristic symbol typ max unit notes package thermal resistance, 20-pin pdip ? ja 62.4 c/w 1 package thermal resistance, 28-pin spdip ? ja 60 c/w 1 package thermal resistance, 20-pin ssop ? ja 108 c/w 1 package thermal resistance, 28-pin ssop ? ja 71 c/w 1 package thermal resistance, 20-pin soic ? ja 75 c/w 1 package thermal resistance, 28-pin soic ? ja 80.2 c/w 1 package thermal resistance, 20-pin qfn ? ja 43 c/w 1 package thermal resistance, 28-pin qfn ? ja 32 c/w 1 package thermal resistance, 44-pin qfn ? ja 29 c/w 1 package thermal resistance, 44-pin tqfp ? ja 40 c/w 1 package thermal resistance, 48-pin uqfn ? ja 41 c/w 1 note 1: junction to ambient thermal resistance, theta- ja ( ? ja ) numbers are achieved by package simulations. table 27-3: dc characteristics: temperature and voltage specifications dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16kmxxx) 2.0v to 5.5v (pic24fv16kmxxx) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min typ ( 1 ) max units conditions dc10 v dd supply voltage 1.8 3.6 v for pic24f devices 2.0 5.5 v for pic24fv devices dc12 v dr ram data retention voltage ( 2 ) 1.6 v for pic24f devices 1.8 v for pic24fv devices dc16 v por v dd start voltage to ensure internal power-on reset signal v ss 0 . 7v dc17 sv dd v dd rise rate to ensure internal power-on reset signal 0.05 v/ms 0-3.3v in 0.1s 0-2.5v in 60 ms note 1: data in typ column is at 3.3v, +25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: this is the limit to which v dd can be lowered without losing ram data. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 269 pic24fv16km204 family table 27-4: high/low-voltag e detect characteristics table 27-5: bor trip points standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min typ max units conditions dc18 v hlvd hlvd voltage on v dd transition hlvdl<3:0> = 0000 ( 2 ) 1 . 9 0v hlvdl<3:0> = 0001 1.88 2.13 v hlvdl<3:0> = 0010 2.09 2.35 v hlvdl<3:0> = 0011 2.25 2.53 v hlvdl<3:0> = 0100 2.35 2.62 v hlvdl<3:0> = 0101 2.55 2.84 v hlvdl<3:0> = 0110 2.80 3.10 v hlvdl<3:0> = 0111 2.95 3.25 v hlvdl<3:0> = 1000 3.09 3.41 v hlvdl<3:0> = 1001 3.27 3.59 v hlvdl<3:0> = 1010 ( 1 ) 3.46 3.79 v hlvdl<3:0> = 1011 ( 1 ) 3.62 4.01 v hlvdl<3:0> = 1100 ( 1 ) 3.91 4.26 v hlvdl<3:0> = 1101 ( 1 ) 4.18 4.55 v hlvdl<3:0> = 1110 ( 1 ) 4.49 4.87 v note 1: these trip points should not be used on pic24fxxkmxxx devices. 2: this trip point should not be used on pic24fvxxkmxxx devices. standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ max units conditions dc15 bor hysteresis 5 mv dc19 bor voltage on v dd transition borv<1:0> = 00 valid for lpbor ( note 1 ) borv<1:0> = 01 2.90 3 3.38 v borv<1:0> = 10 2.53 2.7 3.07 v borv<1:0> = 11 1.75 1.85 2.05 v (note 2 ) borv<1:0> = 11 1.95 2.05 2.16 v (note 3 ) note 1: lpbor re-arms the por circuit but does not cause a bor. 2: this is valid for pic24f (3.3v) devices. 3: this is valid for pic24fv (5v) devices. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 270 ? 2013 microchip technology inc. table 27-6: dc characteristics: operating current (i dd ) dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16kmxxx) 2.0v to 5.5v (pic24fv16kmxxx) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended parameter no. device typical max units conditions i dd current d20 pic24fv16kmxxx 269 450 a 2.0v 0.5 mips, f osc = 1 mhz ( 1 ) 465 830 a 5.0v pic24f16kmxxx 200 330 a 1.8v 410 750 a 3.3v dc22 pic24fv16kmxxx 490 a 2.0v 1 mips, f osc = 2 mhz ( 1 ) 880 a 5.0v pic24f16kmxxx 407 a 1.8v 800 a 3.3v dc24 pic24fv16kmxxx 13.0 15.0 ma 5.0v 16 mips, f osc = 32 mhz ( 1 ) pic24f16kmxxx 12.0 13.0 ma 3.3v dc26 pic24fv16kmxxx 2.0 ma 2.0v frc (4 mips), f osc = 8 mhz 3.5 ma 5.0v pic24f16kmxxx 1.80 ma 1.8v 3.40 ma 3.3v dc30 pic24fv16kmxxx 48.0 250 a 2.0v lprc (15.5 kips), f osc = 31 khz 75.0 275 a 5.0v pic24f16kmxxx 8.1 28.0 a 1.8v 13.50 55.00 a 3.3v legend: unshaded rows represent pic24f16kmxxx devices and shaded rows represent pic24fv16kmxxx devices. note 1: the oscillator is in external clock mode (foscsel<2:0> = 010 , fosc<1:0> = 00 ). downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 271 pic24fv16km204 family table 27-7: dc characteristics: idle current (i idle ) dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16kmxxx) 2.0v to 5.5v (pic24fv16kmxxx) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended parameter no. device typical max units conditions idle current (i idle ) dc40 pic24fv16kmxxx 120 200 a 2.0v 0.5 mips, f osc = 1 mhz ( 1 ) 160 430 a 5.0v pic24f16kmxxx 50 100 a 1.8v 90 370 a 3.3v dc42 pic24fv16kmxxx 165 a 2.0v 1 mips, f osc = 2 mhz ( 1 ) 260 a 5.0v pic24f16kmxxx 95 a 1.8v 180 a 3.3v dc44 pic24fv16kmxxx 3.1 6.5 ma 5.0v 16 mips, f osc = 32 mhz ( 1 ) pic24f16kmxxx 2.9 6.0 ma 3.3v dc46 pic24fv16kmxxx 0.65 ma 2.0v frc (4 mips), f osc = 8 mhz 1.0 ma 5.0v pic24f16kmxxx 0.55 ma 1.8v 1.0 ma 3.3v dc50 pic24fv16kmxxx 42 200 a 2.0v lprc (15.5 kips), f osc = 31 khz 65 225 a 5.0v pic24f16kmxxx 2.2 18 a 1.8v 4.0 40 a 3.3v legend: unshaded rows represent pic24f16kmxxx devices and shaded rows represent pic24fv16kmxxx devices. note 1: the oscillator is in external clock mode (foscsel<2:0> = 010 , fosc<1:0> = 00 ). downloaded from: http:///
pic24fv16km204 family ds30003030b-page 272 ? 2013 microchip technology inc. table 27-8: dc characteristics: power-down current (i pd ) dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended parameter no. device typical ( 1 ) max units conditions power-down current (i pd ) dc60 pic24fv16kmxxx 6.0 a -40c 2.0v sleep mode ( 2 ) 8.0 +25c 8.5 +60c 9.0 +85c 15.0 +125c 6.0 a -40c 5.0v 8.0 +25c 9.0 +60c 10.0 +85c 15.0 +125c pic24f16kmxxx 0.025 a -40c 1.8v 0.80 +25c 1.5 +60c 2.0 +85c 7.5 +125c 0.040 a -40c 3.3v 1.0 +25c 2.0 +60c 3.0 +85c 7.5 +125c dc61 pic24fv16kmxxx 0.25 a +85c 2.0v low-voltage sleep mode ( 2 ) 7.5 +125c 0.35 3.0 a +85c 5.0v 7.5 +125c legend: unshaded rows represent pic24f16kmxxx devices and shaded rows represent pic24fv16kmxxx devices. note 1: data in the typical column is at 3.3v, +25c (pic24f16kmxxx) or 5.0v, +25c (pic24fv16kmxxx) unless otherwise stated. parameters are for design guidance only and are not tested. 2: base i pd is measured with all peripherals and clocks shut down. all i/os are configured as outputs and set low. pmslp is set to 0 and wdt, etc., are all switched off. 3: the ? current is the additional current consumed when the module is enabled. this current should be added to the base i pd current. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 273 pic24fv16km204 family module differential current ( ? i pd ) ( 3 ) dc71 pic24fv16kmxxx 0.50 a 2.0v watchdog timer current: ? wdt 0.70 1.5 a 5.0v pic24f16kmxxx 0.50 a 1.8v 0.70 1.5 a 3.3v dc72 pic24fv16kmxxx 0.80 a 2.0v 32 khz crystal with rtcc, dswdt or timer1: ? sosc (soscsel = 0 ) 1.50 2.0 a 5.0v pic24f16kmxxx 0.70 a 1.8v 1.0 1.5 a 3.3v dc75 pic24fv16kmxxx 5.4 a 2.0v ? hlvd 8.1 14.0 a 5.0v pic24f16kmxxx 4.9 a 1.8v 7.5 14.0 a 3.3v dc76 pic24fv16kmxxx 5.6 a 2.0v ? bor 6.5 11.2 a 5.0v pic24f16kmxxx 5.6 a 1.8v 6.0 11.2 a 3.3v dc78 pic24fv16kmxxx 0.03 a 2.0v low-power bor: ? lpbor 0.05 0.3 a 5.0v pic24f16kmxxx 0.03 a 1.8v 0.05 0.3 a 3.3v table 27-8: dc characteristics: power-down current (i pd ) (continued) dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended parameter no. device typical ( 1 ) max units conditions legend: unshaded rows represent pic24f16kmxxx devices and shaded rows represent pic24fv16kmxxx devices. note 1: data in the typical column is at 3.3v, +25c (pic24f16kmxxx) or 5.0v, +25c (pic24fv16kmxxx) unless otherwise stated. parameters are for design guidance only and are not tested. 2: base i pd is measured with all peripherals and clocks shut down. all i/os are configured as outputs and set low. pmslp is set to 0 and wdt, etc., are all switched off. 3: the ? current is the additional current consumed when the module is enabled. this current should be added to the base i pd current. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 274 ? 2013 microchip technology inc. table 27-9: dc characteristics: i/o pin input specifications dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions v il input low voltage ( 4 ) di10 i/o pins v ss 0.2 v dd v di15 mclr v ss 0.2 v dd v di16 osci (xt mode) v ss 0.2 v dd v di17 osci (hs mode) v ss 0.2 v dd v di18 i/o pins with i 2 c? buffer v ss 0.3 v dd v smbus disabled di19 i/o pins with smbus buffer v ss 0.8 v smbus enabled v ih input high voltage ( 4 , 5 ) di20 i/o pins: with analog functions digital only 0.8 v dd 0.8 v dd v dd v dd vv di25 mclr 0.8 v dd v dd v di26 osci (xt mode) 0.7 v dd v dd v di27 osci (hs mode) 0.7 v dd v dd v di28 i/o pins with i 2 c buffer: with analog functions digital only 0.7 v dd 0.7 v dd v dd v dd vv di29 i/o pins with smbus 2.1 v dd v2 . 5 v ? v pin ? v dd di30 i cnpu cnx pull-up current 50 250 500 ? av dd = 3.3v, v pin = v ss di31 i pu maximum load current for digital high detection w/internal pull-up 3 0 ? av dd = 2.0v 1000 ? av dd = 3.3v i il input leakage current ( 2 , 3 ) di50 i/o ports 0.050 0.100 ? av ss ? v pin ? v dd , pin at high-impedance di51 pins with oaxout functions (rb15 and rb3) 0.100 0.200 ? av ss ? v pin ? v dd , pin at high-impedance note 1: data in typ column is at 3.3v, +25c unless otherwise stated. 2: the leakage current on the mclr pin is strongly dependent on the applied voltage level. the specified levels represent normal operating conditions. higher leakage current may be measured at different input voltages. 3: negative current is defined as current sourced by the pin. 4: refer to ta b l e 1 - 4 and tab l e 1 - 5 for i/o pin buffer types. 5: v ih requirements are met when the internal pull-ups are enabled. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 275 pic24fv16km204 family table 27-10: dc characteristics: i/o pin output specifications dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions v ol output low voltage do10 all i/o pins 0.4 v i ol = 8.0 ma v dd = 4.5v 0 . 4vi ol = 4.0 ma v dd = 3.6v 0 . 4vi ol = 3.5 ma v dd = 2.0v do16 osc2/clko 0.4 v i ol = 2.0 ma v dd = 4.5v 0 . 4vi ol = 1.2 ma v dd = 3.6v 0 . 4vi ol = 0.4 ma v dd = 2.0v v oh output high voltage do20 all i/o pins 3.8 v i oh = -3.5 ma v dd = 4.5v 3vi oh = -3.0 ma v dd = 3.6v 1.6 v i oh = -1.0 ma v dd = 2.0v do26 osc2/clko 3.8 v i oh = -2.0 ma v dd = 4.5v 3vi oh = -1.0 ma v dd = 3.6v 1.6 v i oh = -0.5 ma v dd = 2.0v note 1: data in typ column is at 3.3v, +25c unless otherwise stated. parameters are for design guidance only and are not tested. table 27-11: dc characteristics: program memory dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions program flash memory d130 e p cell endurance 10,000 ( 2 ) e / w d131 v pr v dd for read v min 3 . 6vv min = minimum operating voltage d133a t iw self-timed write cycle time 2m s d134 t retd characteristic retention 40 year provided no other specifications are violated d135 i ddp supply current during programming 1 0m a note 1: data in typ column is at 3.3v, +25c unless otherwise stated. 2: self-write and block erase. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 276 ? 2013 microchip technology inc. table 27-13: dc characteristics: comparator table 27-14: dc characteristics: comparator voltage reference table 27-12: dc characteristics: data eeprom memory dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions data eeprom memory d140 e pd cell endurance 100,000 e/w d141 v prd v dd for read v min 3 . 6vv min = minimum operating voltage d143a t iwd self-timed write cycle time 4 m s d143b t ref number of total write/erase cycles before refresh 1 0 m e / w d144 t retdd characteristic retention 40 year provided no other specifications are violated d145 i ddpd supply current during programming 7 m a note 1: data in typ column is at 3.3v, +25c unless otherwise stated. dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min typ max units conditions d300 v ioff input offset voltage 20 40 mv d301 v icm input common-mode voltage 0 v dd v d302 cmrr common-mode rejection ratio 55 db dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min typ max units conditions vrd310 cv res resolution v dd /32 lsb vrd311 cvr aa absolute accuracy 1 lsb av dd = 3.3v-5.5v vrd312 cvr ur unit resistor value (r) 2k ? downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 277 pic24fv16km204 family table 27-15: internal voltag e regulator specifications operating conditions: -40c < t a < +85c (unless otherwise stated) -40c ? t a ? +125c for extended param no. symbol characteristics min typ max units comments v bg band gap reference voltage 0.973 1.024 1.075 v v dd > 4.5v for 4*v bg reference v dd > 2.3v for 2*v bg reference t bg band gap reference start-up time 1m s v rgout regulator output voltage 3.1 3.3 3.6 v c efc external filter capacitor value 4.7 10 ? f series resistance < 3 ohm recommended; < 5 ohm is required. v lvr low-voltage regulator output voltage 2 . 6v table 27-16: ctmu current source specifications dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units comments conditions i out 1 ctmu current source, base range 550 na ctmucon1l<1:0> = 01 2.5v < v dd < v ddmax i out 2 ctmu current source, 10x range 5 . 5 ? a ctmucon1l<1:0> = 10 i out 3 ctmu current source, 100x range 5 5 ? a ctmucon1l<1:0> = 11 i out 4 ctmu current source, 1000x range 550 ? a ctmucon1l<1:0> = 00 (note 2 ) v f temperature diode forward voltage . 7 6 v v ? voltage change per degree celsius 1 . 6m v / c note 1: nominal value at the center point of t he current trim range (ctmucon1l<7:2> = 000000 ). on pic24f16km parts, the current output is limited to the typical current value when i out 4 is chosen. 2: do not use this current range with a temperature sensing diode. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 278 ? 2013 microchip technology inc. table 27-17: operational amplifier specifications dc characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units comments gbwp gain bandwidth product 5 mhz spdsel = 1 0.5 mhz spdsel = 0 sr slew rate 1.2 v/s spdsel = 1 0.3 v/s spdsel = 0 a ol dc open-loop gain 90 db v ioff input offset voltage 2 10 mv v ibc input bias current na (note 1 ) v icm common-mode input voltage range av ss a v dd v cmrr common-mode rejection ratio 6 0d b psrr power supply rejection ratio 6 0d b v or output voltage range av ss + 200 av ss + 5 to a vdd C 5 av dd C 200 mv 0.5v input overdrive, no output loading note 1: the op amps use cmos input circuitry with negligible input bias current. the maximum effective bias current is the i/o pin leakage specified by electrical parameter di50 . downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 279 pic24fv16km204 family 27.2 ac characteristics and timing parameters the information contained in this section defines the pic24fv16km204 family ac characteristics and timing parameters. table 27-18: temperature and vo ltage specifications C ac figure 27-5: load conditions for device timing specifications table 27-19: capacitiv e loading requirements on output pins ac characteristics standard operating conditions: 1.8v to 3.6v operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended operating voltage v dd range as described in section 27.1 dc characteristics . param no. symbol characteristic min typ ( 1 ) max units conditions do50 c osc 2 osco/clko pin 15 pf in xt and hs modes when external clock is used to drive osci do56 c io all i/o pins and osco 50 pf ec mode do58 c b sclx, sdax 400 pf in i 2 c? mode note 1: data in typ column is at 3.3v, +25c unless otherwise stated. parameters are for design guidance only and are not tested. v dd /2 c l r l pin pin v ss v ss c l r l =464 ? c l = 50 pf for all pins except osco 15 pf for osco output load condition 1 C for all pins except osco load condition 2 C for osco downloaded from: http:///
pic24fv16km204 family ds30003030b-page 280 ? 2013 microchip technology inc. figure 27-6: extern al clock timing osci clko q4 q1 q2 q3 q4 q1 os20 os25 os30 os30 os40 os41 os31 os31 q1 q2 q3 q4 q2 q3 table 27-20: external clo ck timing requirements ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions os10 f osc external clki frequency (external clocks allowed only in ec mode) dc 4 dc 4 32 8 24 6 mhz mhz mhz mhz ec, -40c < t a < +85c ecpll, -40c < t a < +85c ec, -40c < t a < +125c ecpll, -40c < t a < +125c oscillator frequency 0.2 44 4 31 4 25 86 33 mhz mhz mhz mhz khz xths xtpll, -40c < t a < +85c xtpll, -40c < t a < +125c sosc os20 t osc t osc = 1/f osc see parameter os10 for f osc value os25 t cy instruction cycle time ( 2 ) 62.5 dc ns os30 tosl, to s h external clock in (osci) high or low time 0.45 x t osc n se c os31 tosr, to s f external clock in (osci) rise or fall time 2 0n s e c os40 tckr clko rise time ( 3 ) 61 0n s os41 tckf clko fall time ( 3 ) 61 0n s note 1: data in typ column is at 3.3v, +25c unless otherwise stated. parameters are for design guidance only and are not tested. 2: instruction cycle period (t cy ) equals two times the input oscillator time base period. all specified values are based on characterization data for that particular oscillator type, under standard operating conditions, with the device executing code. exceeding these specified limits may result in an unstable oscillator operation and/or higher than expected current consumption. all devices are tested to operate at min. values with an external clock applied to the osci/clki pin. when an external clock input is used, the max. cycle time limit is dc (no clock) for all devices. 3: measurements are taken in ec mode. the clko signal is measured on the osco pin. clko is low for the q1-q2 period (1/2 t cy ) and high for the q3-q4 period (1/2 t cy ). downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 281 pic24fv16km204 family table 27-21: pll clock ti ming specifications ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic ( 1 ) min typ ( 2 ) max units conditions os50 f plli pll input frequency range 4 8 mhz ecpll, hspll modes, -40c ? t a ? +85c os51 f sys pll output frequency range 16 32 mhz -40c ? t a ? +85c os52 t lock pll start-up time (lock time) 1 2m s os53 d clk clko stability (jitter) -2 1 2 % measured over 100 ms period note 1: these parameters are characterized but not tested in manufacturing. 2: data in typ column is at 3.3v, +25c unless otherwise stated. parameters are for design guidance only and are not tested. table 27-22: internal rc oscillator accuracy ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. characteristic min typ max units conditions f20 frc @ 8 mhz ( 1 ) -2 +2 % +25c 3.0v ? v dd ? 3.6v, f device 3.2v ? v dd ? 5.5v, fv device -5 +5 % -40c ? t a ?? +125c 1.8v ? v dd ? 3.6v, f device 2.0v ? v dd ? 5.5v, fv device f21 lprc @ 31 khz ( 2 ) -15 +15 % -40c ? t a ?? +125c 1.8v ? v dd ? 3.6v, f device 2.0v ? v dd ? 5.5v, fv device note 1: the frequency is calibrated at +25c and 3.3v. the osctun bits can be used to compensate for temperature drift. 2: the change of lprc frequency as v dd changes. table 27-23: internal rc oscillator specifications ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ max units conditions t frc frc start-up time 5 ? s t lprc lprc start-up time 70 ? s downloaded from: http:///
pic24fv16km204 family ds30003030b-page 282 ? 2013 microchip technology inc. figure 27-7: clko and i/o ti ming characteristics note: refer to figure 27-5 for load conditions. i/o pin (input) i/o pin (output) di35 old value new value di40 do31 do32 table 27-24: clko and i/o timing requirements ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min typ ( 1 ) max units conditions do31 t io r port output rise time 10 25 ns do32 t io f port output fall time 10 25 ns di35 t inp intx pin high or low time (output) 20 ns di40 t rbp cnx high or low time (input) 2 t cy note 1: data in typ column is at 3.3v, +25c unless otherwise stated. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 283 pic24fv16km204 family figure 27-8: reset, watchdog timer, os cillator start-up timer and power-up timer timing characteristics v dd mclr internal por pwrt sysrst system clock watchdog timer reset sy10 sy20 sy13 i/o pins sy13 sy35 sy11 sy12 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 284 ? 2013 microchip technology inc. figure 27-9: brown-out reset characteristics table 27-25: reset, watchdog timer, oscill ator start-up timer, power-up timer and brown-out reset timing requirements ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min. typ ( 1 ) max. units conditions sy10 tmcl mclr pulse width (low) 2 ? s sy11 t pwrt power-up timer period 50 64 90 ms sy12 t por power-on reset delay 1 5 10 ? s sy13 t ioz i/o high-impedance from mclr low or watchdog timer reset 100 ns sy20 t wdt watchdog timer time-out period 0.85 1.0 1.15 ms 1.32 prescaler 3.4 4.0 4.6 ms 1:128 prescaler sy25 t bor brown-out reset pulse width 1 ? s sy35 t fscm fail-safe clock monitor delay 2 . 0 2 . 3 ? s sy45 t rst internal state reset time 5 ? s sy50 t vreg on-chip voltage regulator output delay 1 0 ? s (note 2 ) sy55 t lock pll start-up time 100 ? s sy65 t ost oscillator start-up time 1024 t osc sy71 t pm program memory wake-up time 1 ? s sleep wake-up with pmslp = 0 sy72 t lvr low-voltage regulator wake-up time 2 5 0 ? s note 1: data in typ column is at 3.3v, +25c unless otherwise stated. 2: this applies to pic24fv16kmxxx devices only. dc19 reset (due to bor) v ddcore (device in brown-out reset) (device not in brown-out reset) t vreg + t rst dc15 sy25 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 285 pic24fv16km204 family table 27-26: comparator timing requirements table 27-27: comparator voltage re ference settling time specifications figure 27-10: capture/compare/pwm timi ngs (mccpx, sccpx modules) table 27-28: capture/compare/pwm re quirements (mccpx, sccpx modules) param no. symbol characteristic min typ max units comments 300 t resp response time * ( 1 ) 150 400 ns 301 t mc 2 ov comparator mode change to output valid * 1 0 ? s * parameters are characterized but not tested. note 1: response time is measured with one comparator input at (v dd C 1.5)/2, while the other input transitions from v ss to v dd . param no. symbol characteristic min typ max units comments vr310 t set settling time ( 1 ) 1 0 ? s note 1: settling time is measured while cvrss = 1 and the cvr<3:0> bits transition from 0000 to 1111 . param no. symbol characteristic min max units conditions 50 t clk l ccpx time base clock source low time t cy /2 ns 51 t clk h ccpx time base clock source high time t cy /2 ns 52 t clk ccpx time base clock source period t cy n s 53 t cc l ccpx capture or gating input low time t clk n s 54 t cc h ccpx capture or gating input high time t clk n s 55 t cc p ccpx capture or gating input period 2 * t clk /n ns n = prescale value (1, 4 or 16) note: refer to figure 27-5 for load conditions. ccpx time base 50 51 52 clock source ccpx capture input (icx) 53 54 55 and gating inputs downloaded from: http:///
pic24fv16km204 family ds30003030b-page 286 ? 2013 microchip technology inc. figure 27-11: example spi ma ster mode timing (cke = 0 ) table 27-29: example spi mode requirements (master mode, cke = 0 ) param no. symbol characteristic min max units conditions 73 t di v2 sc h, t di v2 sc l setup time of sdix data input to sckx edge 20 ns 74 t sc h2 di l, t sc l2 di l hold time of sdix data input to sckx edge 40 ns 75 t do r sdox data output rise time 25 ns 76 t do f sdox data output fall time 25 ns 78 t sc r sckx output rise time (master mode) 25 ns 79 t sc f sckx output fall time (master mode) 25 ns f sck sckx frequency 10 mhz sckx (ckp = 0 ) sckx (ckp = 1 ) sdox sdix 73 74 75, 76 78 79 79 78 msb lsb bit 6 - - - - - - 1 lsb in bit 6 - - - - 1 note: refer to figure 27-5 for load conditions. msb in downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 287 pic24fv16km204 family figure 27-12: example spi ma ster mode timing (cke = 1 ) table 27-30: example spi mode requirements (master mode, cke = 1 ) param. no. symbol characteristic min max units conditions 73 t di v2 sc h, t di v2 sc l setup time of sdix data input to sckx edge 35 ns 74 t sc h2 di l, t sc l2 di l hold time of sdix data input to sckx edge 40 ns 75 t do r sdox data output rise time 25 ns 76 t do f sdox data output fall time 25 ns 78 t sc r sckx output rise time (master mode) 25 ns 79 t sc f sckx output fall time (master mode) 25 ns 81 t do v2 sc h, t do v2 sc l sdox data output setup to sckx edge t cy n s f sck sckx frequency 10 mhz sckx (ckp = 0 ) sckx (ckp = 1 ) sdox sdix 81 74 75, 76 78 msb 79 73 bit 6 - - - - - - 1 lsb in bit 6 - - - - 1 lsb note: refer to figure 27-5 for load conditions. msb in downloaded from: http:///
pic24fv16km204 family ds30003030b-page 288 ? 2013 microchip technology inc. figure 27-13: example spi slave mode timing (cke = 0 ) table 27-31: example spi mode requirements (slave mode timing, cke = 0 ) param no. symbol characteristic min max units conditions 70 t ss l2 sc h, t ss l2 sc l ssx ? to sckx ? or sckx ? input 3 t cy n s 70a t ss l2wb ssx to write to sspxbuf 3 t cy n s 71 t sc h sckx input high time (slave mode) continuous 1.25 t cy + 30 ns 71a single byte 40 ns (note 1 ) 72 t sc l sckx input low time (slave mode) continuous 1.25 t cy + 30 ns 72a single byte 40 ns (note 1 ) 73 t di v2 sc h, t di v2 sc l setup time of sdix data input to sckx edge 20 ns 73a t b 2 b last clock edge of byte 1 to the first clock edge of byte 2 1.5 t cy + 40 ns (note 2 ) 74 t sc h2 di l, t sc l2 di l hold time of sdix data input to sckx edge 40 ns 75 t do r sdox data output rise time 25 ns 76 t do f sdox data output fall time 25 ns 77 t ss h2 do z ssx ? to sdox output high-impedance 10 50 ns 80 t sc h2 do v, t sc l2 do v sdox data output valid after sckx edge 50 ns 83 t sc h2 ss h, t sc l2 ss h ssx ? after sckx edge 1.5 t cy + 40 ns f sck sckx frequency 10 mhz note 1: requires the use of parameter 73a . 2: only if parameters 71a and 72a are used. ssx sckx (ckp = 0 ) sckx (ckp = 1 ) sdox sdix 70 71 72 73 74 75, 76 77 80 msb lsb bit 6 - - - - - - 1 bit 6 - - - - 1 lsb in 83 note: refer to figure 27-5 for load conditions. msb in downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 289 pic24fv16km204 family figure 27-14: example spi slave mode timing (cke = 1 ) table 27-32: example spi slave mode requirements (cke = 1 ) param no. symbol characteristic min max units conditions 70 t ss l2 sc h, t ss l2 sc l ssx ? to sckx ? or sckx ? input 3 t cy n s 70a t ss l2wb ssx to write to sspxbuf 3 t cy n s 71 t sc h sckx input high time (slave mode) continuous 1.25 t cy + 30 ns 71a single byte 40 ns (note 1 ) 72 t sc l sckx input low time (slave mode) continuous 1.25 t cy + 30 ns 72a single byte 40 ns (note 1 ) 73a t b 2 b last clock edge of byte 1 to the first clock edge of byte 2 1.5 t cy + 40 ns (note 2 ) 74 t sc h2 di l, t sc l2 di l hold time of sdix data input to sckx edge 40 ns 75 t do r sdox data output rise time 25 ns 76 t do f sdox data output fall time 25 ns 77 t ss h2 do z ssx ? to sdox output high-impedance 10 50 ns 80 t sc h2 do v, t sc l2 do v sdox data output valid after sckx edge 50 ns 82 t ss l2 do v sdox data output valid after ssx ? edge 50 ns 83 t sc h2 ss h, t sc l2 ss h ssx ? after sckx edge 1.5 t cy + 40 ns f sck sckx frequency 10 mhz note 1: requires the use of parameter 73a . 2: only if parameters 71a and 72a are used. ssx sckx (ckp = 0 ) sckx (ckp = 1 ) sdox 71 72 82 sdix 74 75, 76 msb bit 6 - - - - - - 1 lsb 77 bit 6 - - - - 1 lsb in 80 83 73 msb in note: refer to figure 27-5 for load conditions. 70 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 290 ? 2013 microchip technology inc. figure 27-15: i 2 c? bus start/stop bits timing table 27-33: i 2 c? bus start/stop bits requirements (slave mode) figure 27-16: i 2 c? bus data timing param. no. symbol characteristic min max units conditions 90 t su : sta start condition setup time 100 khz mode 4700 ns only relevant for repeated start condition 400 khz mode 600 91 t hd : sta start condition hold time 100 khz mode 4000 ns after this period, the first clock pulse is generated 400 khz mode 600 92 t su : sto stop condition setup time 100 khz mode 4700 ns 400 khz mode 600 93 t hd : sto stop condition hold time 100 khz mode 4000 ns 400 khz mode 600 note: refer to figure 27-5 for load conditions. sclx sdax start condition stop condition 90 91 92 93 note: refer to figure 27-5 for load conditions. 90 91 92 100 101 103 106 107 109 109 110 102 sclx sdax in sdax out downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 291 pic24fv16km204 family table 27-34: i 2 c? bus data requirements (slave mode) param. no. symbol characteristic min max units conditions 100 t high clock high time 100 khz mode 4.0 ? s must operate at a minimum of 1.5 mhz 400 khz mode 0.6 ? s must operate at a minimum of 10 mhz msspx module 1.5 t cy 101 t low clock low time 100 khz mode 4.7 ? s must operate at a minimum of 1.5 mhz 400 khz mode 1.3 ? s must operate at a minimum of 10 mhz msspx module 1.5 t cy 102 t r sdax and sclx rise time 100 khz mode 1000 ns 400 khz mode 20 + 0.1 c b 300 ns c b is specified to be from 10 to 400 pf 103 t f sdax and sclx fall time 100 khz mode 300 ns 400 khz mode 20 + 0.1 c b 300 ns c b is specified to be from 10 to 400 pf 90 t su : sta start condition setup time 100 khz mode 4.7 ? s only relevant for repeated start condition 400 khz mode 0.6 ? s 91 t hd : sta start condition hold time 100 khz mode 4.0 ? s after this period, the first clock pulse is generated 400 khz mode 0.6 ? s 106 t hd : dat data input hold time 100 khz mode 0 ns 400 khz mode 0 0.9 ? s 107 t su : dat data input setup time 100 khz mode 250 ns (note 2 ) 400 khz mode 100 ns 92 t su : sto stop condition setup time 100 khz mode 4.7 ? s 400 khz mode 0.6 ? s 109 t aa output valid from clock 100 khz mode 3500 ns (note 1 ) 400 khz mode ns 110 t buf bus free time 100 khz mode 4.7 ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? s d102 c b bus capacitive loading 400 pf note 1: as a transmitter, the device must provide this internal mini mum delay time to bridge the undefined region (min. 300 ns) of the falling edge of sclx to avoid unintended generation of start or stop conditions. 2: a fast mode i 2 c? bus device can be used in a standard mode i 2 c bus system, but the requirement, t su : dat ? 250 ns, must then be met. this will automatically be the case if the device does not stretch the low period of the sclx signal. if such a device does stretch the low period of the sclx signal, it must output the next data bit to the sdax line, t r max. + t su : dat = 1000 + 250 = 1250 ns (according to the standard mode i 2 c bus specification), before the sclx line is released. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 292 ? 2013 microchip technology inc. figure 27-17: msspx i 2 c? bus start/stop bits timing waveforms table 27-35: i 2 c? bus start/stop bits requirements (master mode) param. no. symbol characteristic min max units conditions 90 t su : sta start condition setup time 100 khz mode 2(t osc )(brg + 1) ns only relevant for repeated start condition 400 khz mode 2(t osc )(brg + 1) 91 t hd : sta start condition hold time 100 khz mode 2(t osc )(brg + 1) ns after this period, the first clock pulse is generated 400 khz mode 2(t osc )(brg + 1) 92 t su : sto stop condition setup time 100 khz mode 2(t osc )(brg + 1) ns 400 khz mode 2(t osc )(brg + 1) 93 t hd : sto stop condition hold time 100 khz mode 2(t osc )(brg + 1) ns 400 khz mode 2(t osc )(brg + 1) note: refer to figure 27-5 for load conditions. sclx sdax start condition stop condition 91 90 93 92 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 293 pic24fv16km204 family figure 27-18: msspx i 2 c? bus data timing table 27-36: i 2 c? bus data requirements (master mode) param. no. symbol characteristic min max units conditions 100 t high clock high time 100 khz mode 2(t osc )(brg + 1) 400 khz mode 2(t osc )(brg + 1) 101 t low clock low time 100 khz mode 2(t osc )(brg + 1) 400 khz mode 2(t osc )(brg + 1) 102 t r sdax and sclx rise time 100 khz mode 1000 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 103 t f sdax and sclx fall time 100 khz mode 300 ns c b is specified to be from 10 to 400 pf 400 khz mode 20 + 0.1 c b 300 ns 90 t su : sta start condition setup time 100 khz mode 2(t osc )(brg + 1) only relevant for repeated start condition 400 khz mode 2(t osc )(brg + 1) 91 t hd : sta start condition hold time 100 khz mode 2(t osc )(brg + 1) after this period, the first clock pulse is generated 400 khz mode 2(t osc )(brg + 1) 106 t hd : dat data input hold time 100 khz mode 0 ns 400 khz mode 0 0.9 ? s 107 t su : dat data input setup time 100 khz mode 250 ns (note 1 ) 400 khz mode 100 ns 92 t su : sto stop condition setup time 100 khz mode 2(t osc )(brg + 1) 400 khz mode 2(t osc )(brg + 1) 109 t aa output valid from clock 100 khz mode 3500 ns 400 khz mode 1000 ns 110 t buf bus free time 100 khz mode 4.7 ? s time the bus must be free before a new transmission can start 400 khz mode 1.3 ? s d102 c b bus capacitive loading 400 pf note 1: a fast mode i 2 c bus device can be used in a standard mode i 2 c bus system, but parameter 107 ? 250 ns must then be met. this will automatically be the case if the device does not stretch the low period of the sclx signal. if such a device does stretch the low period of the sclx signal, it must output the next data bit to the sdax line, parameter 102 + parameter 107 = 1000 + 250 = 1250 ns (for 100 khz mode), before the sclx line is released. note: refer to figure 27-5 for load conditions. 90 91 92 100 101 103 106 107 109 109 110 102 sclx sdax in sdax out downloaded from: http:///
pic24fv16km204 family ds30003030b-page 294 ? 2013 microchip technology inc. table 27-37: a/d mo dule specifications ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. symbol characteristic min. typ max. units conditions device supply ad01 av dd module v dd supply greater of: v dd C 0.3 or 1.8 lesser of: v dd + 0.3 or 3.6 v pic24fxxkmxxx devices greater of: v dd C 0.3 or 2.0 lesser of: v dd + 0.3 or 5.5 v pic24fvxxkmxxx devices ad02 av ss module v ss supply v ss C 0.3 v ss + 0.3 v reference inputs ad05 v refh reference voltage high av ss + 1.7 av dd v ad06 v refl reference voltage low av ss a v dd C 1.7 v ad07 v ref absolute reference voltage av ss C 0.3 av dd + 0.3 v ad08 i vref reference voltage input current 1 . 2 5 m a ad09 z vref reference input impedance 1 0 k ? analog input ad10 v inh -v inl full-scale input span v refl v refh v (note 2 ) ad11 v in absolute input voltage av ss C 0.3 av dd + 0.3 v ad12 v inl absolute v inl input voltage av ss C 0.3 av dd /2 v ad17 r in recommended impedance of analog voltage source 1 k ? 12-bit a/d accuracy ad20b n r resolution 12 bits ad21b inl integral nonlinearity 1 9 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad22b dnl differential nonlinearity 1 5 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad23b g err gain error 1 9 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad24b e off offset error 1 5 lsb v inl = av ss = v refl = 0v, av dd = v refh = 5v ad25b monotonicity ( 1 ) guaranteed note 1: the a/d conversion result never decreases with an increase in the input voltage. 2: measurements are taken with external v ref + and v ref - used as the a/d voltage reference. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 295 pic24fv16km204 family figure 27-19: a/d conversion timing table 27-38: a/d conversion timing requirements ( 1 ) ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min. typ max. units conditions clock parameters ad50 t ad a/d clock period 600 ns t cy = 75 ns, ad1con3 in default state ad51 t rc a/d internal rc oscillator period 1.67 s conversion rate ad55 t conv conversion time 1214 t ad t ad 10-bit results 12-bit results ad56 f cnv throughput rate 100 ksps ad57 t samp sample time 1 t ad ad58 t acq acquisition time 750 ns (note 2 ) ad59 t swc switching time from convert to sample (note 3 ) ad60 t dis discharge time 12 t ad clock parameters ad61 t pss sample start delay from setting sample bit (samp) 2 3 t ad note 1: because the sample caps will eventually lose charge, clock rates below 10 khz can affect linearit y performance, especially at elevated temperatures. 2: the time for the holding capacitor to acquire the new input voltage w hen the voltage changes full scale after the conversion (v dd to v ss or v ss to v dd ). 3: on the following cycle of the device clock. ad55 ad50 ad58 bclr ad1con1, samp q3/q4 a/d clk (1) a/d data adc1bufx ad1if samp old data sampling stopped new data (note 2) 11 10 9 2 1 0 note 1: if the a/d clock source is selected as rc, a time of t cy is added before the a/d clock starts. this allows the sleep instruction to be executed. 2: this is a minimal rc delay (typically 100 ns) which also disconnects the holding capacitor from the analog input. . . . . . . t cy bset ad1con1, samp ad59 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 296 ? 2013 microchip technology inc. table 27-39: 8-bit digital-to- analog converter specifications ac characteristics standard operating conditions: 1.8v to 3.6v (pic24f16km204) 2.0v to 5.5v (pic24fv16km204) operating temperature -40c ? t a ? +85c for industrial -40c ? t a ? +125c for extended param no. sym characteristic min. typ max. units comments resolution 8 bits dacref<1:0> input voltage range av ss + 1.8 av dd v differential linearity error (dnl) 0 . 5l s b integral linearity error (inl) 1.5 lsb offset error 0.5 lsb gain error 3.0 lsb monotonicity (note 1 ) output voltage range av ss + 50 av ss + 5 to av dd C 5 av dd C 50 mv 0.5v input overdrive, no output loading slew rate 5 v/s settling time 10 s note 1: dac output voltage never decreases with an increase in the data code. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 297 pic24fv16km204 family 28.0 packaging information 28.1 package marking information legend: xx...x product-specific information y year code (last digit of calendar year) yy year code (last 2 digits of calendar year) ww week code (week of january 1 is week 01) nnn alphanumeric traceability code pb-free jedec designator for matte tin (sn) * this package is pb-free. the pb-free jedec designator ( ) can be found on the outer packaging for this package. note: in the event the full microchip part number cannot be marked on one line, it will be carried over to the next line, thus limiting the number of available characters for customer-specific information. 3 e 3 e 20-lead pdip (300 mil) xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx yywwnnn 3 e example -i/p pic24f08km101 1342m7w 20-lead ssop (5.30 mm) xxxxxxxxxxx xxxxxxxxxxx yywwnnn example 24f08km101 301-i/ss 1342m7w 3 e 20-lead soic (7.50 mm) xxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxx yywwnnn example pic24f08km101 -i/so 1342m7w 3 e xxxxxxx 20-lead qfn xxxxxxx yywwnnn 24f08km example 101/ml 1310017 3 e downloaded from: http:///
pic24fv16km204 family ds30003030b-page 298 ? 2013 microchip technology inc. pin 1 28-lead soic (7.50 mm) xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx yywwnnn example pic24f16km202 1342m7w 28-lead qfn (6x6 mm) xxxxxxxx xxxxxxxx yywwnnn 3 e -i/so example f16km202 -i/ml 1342m7w 3 e pin 1 28-lead spdip (.300") xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx yywwnnn example -i/sp pic24f16km202 1342m7w 3 e 28-lead ssop (5.30 mm) xxxxxxxxxxxx xxxxxxxxxxxx yywwnnn example pic24f16km 102-i/ss 1342m7w 3 e 44-lead tqfp (10x10x1 mm) xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx yywwnnn 24fv16km 204-i/pt 1342m7w 3 e example downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 299 pic24fv16km204 family xxxxxxxxxxx 44-lead qfn (8x8x0.9 mm) xxxxxxxxxxx xxxxxxxxxxx yywwnnn example 3 e pin 1 pic24fv16km example 204-i/ml 1342m7w pin 1 x xxxxxxxxxxx xxxxxxxxxxx yywwnnn xxxxxxxx 48-lead uqfn (6x6x0.5 mm) xxxxxxxx yywwnnn 3 e pin 1 24fv16km 204/mv 1342m7w pin 1 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 300 ? 2013 microchip technology inc. 28.2 package details the following sections give the technical details of the packages. 
    
     

       !" # $% &" '  ()"&'"!&)  & #*&&  & #    + % &,  & !& - ' !! #.#&"# '#% !
&"!!#% !
&"!!! & $ #/
!#   ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 7,8. ' !9'&! 7 7: ; 7"') %! 7  & 1, 
& &    < <  # # 4 4 !!   -  1 ! & &     < < "# &"# =#& . - - - # # 4 =#& .   > :  9  &  > - ? 
& &   9  -  9 #4 !!  >   6
9 #=#& )  ?  9* 9 #=#& )  >  :  *
 + 1 < < - n e1 note 1 d 123 a a1 a2 l e b1 b e c eb 
    * , 1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 301 pic24fv16km204 family 
  !"#  $     %&    $
      !" # $% &" '  ()"&'"!&)  & #*&&  & #    ' !! #.#&"# '#% !
&"!!#% !
&"!!! & $ #''
!#  - ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   ! .32  %   ' !("!" *&"&&   (%%' &
"
! !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 99.. ' !9'&! 7 7: ; 7"') %! 7  & ?1, :  8  &  < <  # # 4 4 !!  ?  > & #%%   < < :  =#& .  > > # # 4 =#& .  - ? :  9  &  ?   3&9  & 9    3&
& 9 .3 9 #4 !!   <  3&  @ @ >@ 9 #=#& )  < -> l l1 a2 c e b a1 a 12 note 1 e1 e d n 
    * , 1 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 302 ? 2013 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 303 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 304 ? 2013 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 305 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 306 ? 2013 microchip technology inc. 
  ' (  )  
#* +  ,-,-&.   '(       !" # $% &" '  ()"&'"!&)  & #*&&  & #     4 !! *! " & # - ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   ! .32  %   ' !("!" *&"&&   (%%' &
"
! !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 99.. ' !9'&! 7 7: ; 7"') %! 7  & 1, :  8  &  >   & #%%     ,& &4 !! - .3 :  =#& . 1, .$
! # #=#& . ?  > :  9  &  1, .$
! # #9  &  ?  > ,& &=#& ) >  - ,& &9  & 9 -   ,& & & .$
! # # a  < < d exposed pad e e2 21 n top view note 1 n l k b e d2 2 1 a a1 a3 bottom view 
    * , ?1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 307 pic24fv16km204 family   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  downloaded from: http:///
pic24fv16km204 family ds30003030b-page 308 ? 2013 microchip technology inc. / #
    
     

      !" # $% &" '  ()"&'"!&)  & #*&&  & #    + % &,  & !& - ' !! #.#&"# '#% !
&"!!#% !
&"!!! & $ #/
!#   ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 7,8. ' !9'&! 7 7: ; 7"') %! 7 > & 1, 
& &    < <  # # 4 4 !!   -  1 ! & &     < < "# &"# =#& .  - -- # # 4 =#& .  >  :  9  &  - -?  
& &   9  -  9 #4 !!  >   6
9 #=#& )    9* 9 #=#& )  >  :  *
 + 1 < < - note 1 n 12 d e1 eb c e l a2 e b b1 a1 a 3 
    * , 1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 309 pic24fv16km204 family /
  !"#  $     %&    $
      !" # $% &" '  ()"&'"!&)  & #*&&  & #    ' !! #.#&"# '#% !
&"!!#% !
&"!!! & $ #''
!#  - ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   ! .32  %   ' !("!" *&"&&   (%%' &
"
! !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 99.. ' !9'&! 7 7: ; 7"') %! 7 > & ?1, :  8  &  < <  # # 4 4 !!  ?  > & #%%   < < :  =#& .  > > # # 4 =#& .  - ? :  9  &     3&9  & 9    3&
& 9 .3 9 #4 !!   <  3&  @ @ >@ 9 #=#& )  < -> l l1 c a2 a1 a e e1 d n 1 2 note 1 b e 
    * , -1 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 310 ? 2013 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 311 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 312 ? 2013 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 313 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 314 ? 2013 microchip technology inc. /
  ' (  )  
#* +  0-0   '( 1 ! &%%  2  * !      !" # $% &" '  ()"&'"!&)  & #*&&  & #     4 !! *! " & # - ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   ! .32  %   ' !("!" *&"&&   (%%' &
"
! !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 99.. ' !9'&! 7 7: ; 7"') %! 7 > & ?1, :  8  &  >   & #%%     ,& &4 !! - .3 :  =#& . ?1, .$
! # #=#& . -? -  :  9  &  ?1, .$
! # #9  &  -? -  ,& &=#& ) - - - ,& &9  & 9    ,& & & .$
! # # a  < < d exposed d2 e b k e2 e l n note 1 1 2 2 1 n a a1 a3 top view bottom view pad 
    * , 1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 315 pic24fv16km204 family /
  ' (  )  
#* +  0-0   '( 1 ! &%%  2  * !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  downloaded from: http:///
pic24fv16km204 family ds30003030b-page 316 ? 2013 microchip technology inc. ,,
  3! ' (  4# 
3  5-5-5  ) &  3'(
      !" # $% &" '  ()"&'"!&)  & #*&&  & #    , '% ! & !  
& b!c '   - ' !! #.#&"# '#% !
&"!!#% !
&"!!! & $ #''
!#   ' !  #&   
.0 1,2 1 !' !  &  $ & " !**&"&&   ! .32  %   ' !("!" *&"&&   (%%' &
"
! !   3& '!&" &
4 # * !(
 ! ! & 
 4  
% & & # & &&
255***'
'5
4  6&! 99.. ' !9'&! 7 7: ; 7"') %9 #! 7  9 #& >1, :  8  &  < <  # # 4 4 !!     & #%%   <  3&9  & 9  ?  3&
& 9 .3 3&  @ -@ @ :  =#& . 1, :  9  &  1, # # 4 =#& . 1, # # 4 9  &  1, 9 #4 !!   <  9 #=#& ) - -  # %&  
@ @ -@ # %&  1&&' @ @ -@ a e e1 d d1 e b note 1 note 2 n 123 c a1 l a2 l1 
    * , ?1 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 317 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 318 ? 2013 microchip technology inc. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 319 pic24fv16km204 family downloaded from: http:///
pic24fv16km204 family ds30003030b-page 320 ? 2013 microchip technology inc. downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 321 pic24fv16km204 family note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
pic24fv16km204 family ds30003030b-page 322 ? 2013 microchip technology inc. note: for the most current package drawings, please see the microchip packaging specification located at http://www.microchip.com/packaging downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 323 pic24fv16km204 family downloaded from: http:///
pic24fv16km204 family ds30003030b-page 324 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 325 pic24fv16km204 family appendix a: revision history revision a (february 2013) original data sheet for the pic24fv16km204 family of devices. revision b (july 2013) updates all references to pgcx and pgdx pin functions throughout the document to pgecx and pgedx. updates section 4.0 memory organization to change bit 12 in the following registers to reserved (r designation): ccp1con1l ( table 4-8 ) ccp2con1l ( table 4-9 ) ccp3con1l ( table 4-10 ) ccp4con1l ( table 4-11 ) ccp5con1l ( table 4-12 ) updates section 13.0 capture/compare/pwm/ timer modules (mccp and sccp) : replaces bit 12 of ccpxcon1l (ccpslp) and its description with a reserved bit removes references to asynchronous operation in sleep mode (and in other occurrences throughout the document) modifies section 13.1 time base generator to add synchronous operation limitations; adds table 13-1 to list valid clock options for all operating modes removes the system clock as a time base input option removes external input sources, comparators and ctmu as synchronization sources in table 13-6 ; clarifies that other selected sources must be synchronous removes the input buffer from the band gap reference input in figure 20-1 . adds bufcon0 register description ( register 20-2 ) to section 20.0 8-bit digital-to-analog converter (dac) . changes references to internal band gap voltages (v bg , v bg /2 and bgbuf0) in section 20.0 8-bit digital-to-analog converter (dac) and section 22.0 comparator module to bgbuf1. adds minimum v dd conditions for v bg specification in table 27-15 (internal voltage regulator specifications). other minor typographical corrections throughout the document. downloaded from: http:///
pic24fv16km204 family ds30003030b-page 326 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 327 pic24fv16km204 family index a a/d buffer data formats ................................................. 225 control registers ..................................................... 21 2 ad1chith/l .................................................... 212 ad1chs .......................................................... 212 ad1con1 ........................................................ 212 ad1con2 ........................................................ 212 ad1con3 ........................................................ 212 ad1con5 ........................................................ 212 ad1cssh/l ..................................................... 212 ad1ctmenh/l ............................................... 212 sampling requirements ........................................... 223 transfer function ..................................................... 224 ac characteristics 8-bit dac specifications .......................................... 296 a/d conversion requirements ................................ 295 a/d module specifications ....................................... 294 capacitive loading requirements on output pins ...................................................... 279 clko and i/o requirements ................................... 282 external clock requirements .................................. 280 internal rc accuracy ............................................... 281 internal rc oscillator specifications ........................ 281 load conditions and requirements ......................... 279 pll clock specification ........................................... 281 reset, watchdog timer. oscillator start-up timer, power-up timer, brown-out reset requirements ................................................ .. 284 temperature and voltage specific ations ................. 279 assembler mpasm assembler .................................................. 262 b block diagrams 12-bit a/d converter ................................................ 210 12-bit a/d converter analog input model ................ 223 16-bit timer1 ........................................................... 141 32-bit timer mode ........................................... ........ 146 accessing program memory with table instructions .............................................. 65 call stack frame ..................................................... 63 clcx input source selection ................................... 197 clcx logic function combinatorial options ........... 196 clcx module ........................................................... 195 comparator voltage reference ............................... 239 comparator x module .............................................. 235 conceptual mccpx/sccpx modules ...................... 143 cpu programmers model ......................................... 37 ctmu connections, internal configuration for capacitance measurement .............................. 242 ctmu connections, internal configuration for pulse delay generation ................................... 243 ctmu connections, internal configuration for time measurement .......................................... 242 data access from program space address generation 64 data eeprom addressing with tblpag and nvm registers ................................................... 75 dual 16-bit timer mode ........................................... 145 high/low-voltage detect (hlvd) ............................ 207 individual comparator configurations ...................... 236 input capture x module ......................................... ... 148 mclr pin connections example .............................. 30 msspx (i 2 c master mode) ...................................... 161 msspx (i 2 c mode) .................................................. 161 msspx (spi mode) ............................................. .... 160 on-chip voltage regulator connections ................ 257 output compare x module ...................................... 147 pic24f cpu core ..................................................... 36 pic24fxxxxx family (general) ............................... 19 psv operation ........................................................... 66 recommended minimum connections ...................... 29 reset system ............................................................ 79 rtcc module ................................................ .......... 181 series resistor ........................................................ 132 shared i/o port structure ........................................ 1 37 simplified single dacx module ............................... 229 simplified uartx .................................................... 173 single operational amplifier .................................... 233 spi master/slave connection .................................. 160 suggested oscillator circuit placement .................... 33 system clock ........................................................... 121 table register addressing ........................................ 67 timer clock generator .......................................... .. 144 watchdog timer (wdt) ......................................... .. 258 brown-out reset trip points ............................................................... 269 c c compilers mplab xc compilers ............................................. 262 capture/compare/pwm/timer auxiliary output ....................................................... 149 general purpose timer ........................................... 145 input capture mode ........................................... ...... 148 output compare mode ............................................ 147 synchronization sources ......................................... 153 time base generator ......................................... ..... 144 capture/compare/pwm/timer (mccp, sccp) .............. 143 charge time measurement unit. see ctmu. clc control registers ..................................................... 198 code examples assembly code sequence for clock switching ....... 128 c code power-saving entry .................................... 131 c code sequence for clock switching .................... 128 data eeprom bulk erase ........................................ 77 data eeprom unlock sequence ............................. 73 erasing a program memory row, assembly language .......................................... 70 erasing a program memory row, c language ......... 70 i/o port write/read ....................................... .......... 140 initiating a programming sequence, assembly language .......................................... 72 initiating a programming sequence, c language ..... 72 loading the write buffers, assembly language ....... 71 loading the write buffers, c language .................... 71 reading data eeprom using tblrd command ............................................. 78 setting the rtcwren bit in c .............................. 182 setting the rtcwren bit in assembly .................. 182 single-word erase .................................................... 76 single-word write to data eeprom ........................ 77 ultra low-power wake-up initialization ................... 132 code protection ............................................................... 259 comparator ...................................................................... 235 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 328 ? 2013 microchip technology inc. comparator voltage reference ...................................... . 239 configuring ............................................................... 239 configurable logic cell (clc) ......................................... 195 configuration bits ............................................................. 249 cpu alu ............................................................................ 39 control registers ....................................................... 38 core registers ........................................................... 36 programmers model ................................................ .. 35 ctmu measuring capacitance ........................................... 241 measuring time ....................................................... 242 pulse generation and delay .................................... 243 customer change notification service ............................ 332 customer notification service .......................................... 332 customer support .............................................. .............. 332 d data eeprom memory ..................................................... 73 erasing ....................................................................... 76 operations ................................................................. 75 programming bulk erase .......................................................... 77 reading data eeprom .................................... 78 single-word write .............................................. 77 programming control registers nvmadr(u) ...................................................... 75 nvmcon ........................................................... 73 nvmkey ............................................................ 73 data memory address space ........................................................... 43 width .................................................................. 43 near data space ....................................................... 44 organization, alignment ........................................... .. 44 sfr space ................................................................. 44 software stack ........................................................... 63 data space memory map .............................................................. 43 dc characteristics bor trip points ....................................................... 269 comparator .............................................................. 276 ctmu current source ............................................. 277 data eeprom memory ........................................... 276 high/low-voltage detect ......................................... 269 i/o pin input specifications .................................... .. 274 i/o pin output specifications ................................... 275 idle current (i idle ) ................................................... 271 internal voltage regulator ....................................... 277 operating current (i dd ) ............................................ 270 operational amplifier ............................................. .. 278 power-down current (i pd ) ....................................... 272 program memory ..................................................... 275 temperature and voltage specific ations ................. 268 demo/development boards, evaluation and starter kits ............................................................... 264 development support .............................................. ........ 261 third-party tools ..................................................... 264 device features pic24f16km104 family .......................................... .. 16 pic24f16km204 family .......................................... .. 15 pic24fv16km104 family ......................................... 18 pic24fv16km204 family ......................................... 17 device overview ................................................................ 13 core features ............................................................ 13 other special features .............................................. 14 pinout description ............................................ .......... 20 dual operational amplifier ........................................... .... 233 e electrical characteristics absolute maximum ratings ..................................... 265 thermal operating conditions ................................. 268 thermal packaging .................................................. 268 equations a/d conversion clock period .................................. 223 uartx baud rate with brgh = 0 .......................... 174 uartx baud rate with brgh = 1 .......................... 174 errata ................................................................................. 11 examples baud rate error calculation (brgh = 0) ................ 174 f flash program memory control registers ....................................................... 6 8 enhanced icsp operation ........................................ 68 programming algorithm ............................................. 70 programming operations ........................................... 68 rtsp operation ........................................................ 68 table instructions ...................................................... 67 g getting started guidelines ................................................. 29 external oscillator pins .............................................. 33 icsp pins .................................................................. 32 master clear (mclr ) pin .......................................... 30 power supply pins .............................................. ....... 30 unused i/os ............................................................... 33 voltage regulator pin (v cap ) .................................... 31 h high/low-voltage detect (hlvd) .................................... 207 i i/o ports analog port pins configuration ................................ 138 analog selection registers ...................................... 138 input change notification ...................................... .. 140 open-drain configuration ........................................ 138 parallel (pio) ........................................................... 137 in-circuit debugger ............................................. ............. 259 in-circuit serial programming (icsp) ............................ .. 259 inter-integrated circuit. see i 2 c. internet address .............................................................. 332 interrupts alternate interrupt vector table (aivt) ..................... 85 control and status registers ..................................... 88 implemented vectors ................................................. 87 interrupt vector table (ivt) ....................................... 85 reset sequence ............................................... ......... 85 setup procedures .................................................... 119 trap vectors .............................................................. 87 vector table .............................................................. 86 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 329 pic24fv16km204 family m master synchronous serial port (mssp) ......................... 159 microchip internet web site ............................................. 332 mplab assembler, linker, librarian ............................... 262 mplab icd 3 in-circuit debugger .................................. 263 mplab pm3 device programmer ................................... 263 mplab real ice in-circuit emulator system ................ 263 mplab x integrated development environment software .............................................. 261 mplab x sim software simulator ................................... 263 mplib object librarian .................................................... 262 mplink object linker ..................................................... 2 62 n near data space ............................................................... 44 o on-chip voltage regulator ........................................... ... 257 oscillator configuration clock switching ........................................................ 127 sequence .................................................. ....... 127 configuration bit values for clock selection ........... 122 control registers ..................................................... 12 3 cpu clocking scheme ............................................ 122 initial configuration on por .................................... 122 reference clock output ........................................... 128 p packaging details ...................................................................... 300 marking .................................................................... 297 pickit 3 in-circuit debugger/programmer ....................... 263 power-saving ................................................................... 135 power-saving features ................................................. .. 131 clock frequency, clock switching ........................... 131 coincident interrupts .......................................... ...... 132 instruction-based modes ......................................... 131 idle ................................................................... 132 sleep ................................................... ............. 131 retention regulator (retreg) ............................... 134 selective peripheral control .................................... 135 ultra low-power wake-up (ulpwu) ....................... 132 voltage regulator-based ......................................... 134 retention sleep mode ..................................... 134 run mode .................................................. ...... 134 sleep mode .................................................. .... 134 product identification system .......................................... 334 program and data memory access using table instructions ................................ 65 program space visibility ............................................ 66 program and data memory spaces interfacing, addressing .............................................. 63 program memory address space ........................................................... 41 configuration word addresses .................................. 4 2 program space memory map .............................................................. 41 program verification ........................................................ 259 r real-time clock and calendar (rtcc) ........................... 181 register maps a/d ............................................................................. 59 ansel ....................................................................... 60 band gap buffer control .......................................... .. 61 clc1-2 ....................................................................... 48 clock control ............................................................. 62 comparator ................................................................ 61 cpu core .................................................................. 45 ctmu ........................................................................ 60 dac1 ......................................................................... 56 dac2 ......................................................................... 56 icn ............................................................................ 46 interrupt controller ..................................................... 47 mccp1 ...................................................................... 49 mccp2 ...................................................................... 50 mccp3 ...................................................................... 51 mssp1 (i 2 c/spi) ....................................................... 54 mssp2 (i 2 c/spi) ....................................................... 54 nvm ........................................................................... 62 op amp 1 .................................................................. 56 op amp 2 .................................................................. 56 pad configuration ...................................................... 58 pmd ........................................................................... 62 porta ...................................................................... 57 portb ...................................................................... 57 portc ...................................................................... 57 real-time clock and calendar ................................. 60 sccp4 ....................................................................... 52 sccp5 ....................................................................... 53 timer1 ....................................................................... 48 uart1 ....................................................................... 55 uart2 ....................................................................... 55 ultra low-power wake-up ......................................... 62 registers ad1chith (a/d scan compare hit, high word) ...................................................... 219 ad1chitl (a/d scan compare hit, low word) ....................................................... 220 ad1chs (a/d sample select) ................................ 218 ad1con1 (a/d control 1) ....................................... 213 ad1con2 (a/d control 2) ....................................... 215 ad1con3 (a/d control 3) ....................................... 216 ad1con5 (a/d control 5) ....................................... 217 ad1cssh (a/d input scan select, high word) ...... 221 ad1cssl (a/d input scan select, low word) ....... 221 ad1ctmenh (ctmu enable, high word) ............. 222 ad1ctmenl (ctmu enable, low word) ............... 222 alcfgrpt (alarm configuration) .......................... 186 alminsec (alarm minutes and seconds value) ............................................... 190 almthdy (alarm month and day value) ............... 189 alwdhr (alarm weekday and hours value) ........ 189 ampxcon (op amp x control) ............................... 234 ansa (porta analog selection) ........................... 138 ansb (portb analog selection) ........................... 139 ansc (portc analog selection) ........................... 139 bufcon0 (internal voltage reference control 0) ......................................................... 232 ccpxcon1h (ccpx control 1 high) ...................... 152 ccpxcon1l (ccpx control 1 low) ....................... 150 ccpxcon2h (ccpx control 2 high) ...................... 155 ccpxcon2l (ccpx control 2 low) ....................... 154 ccpxcon3h (ccpx control 3 high) ...................... 157 ccpxcon3l (ccpx control 3 low) ....................... 156 ccpxstatl (ccpx status) .................................... 158 clcxconh (clcx control high) ............................ 199 clcxconl (clcx control low) ............................. 198 clcxglsh (clcx gate logic input select high) ... 204 clcxglsl (clcx gate logic input select low) .... 202 clcxsel (clcx input mux select) ....................... 200 clkdiv (clock divider) ........................................... 125 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 330 ? 2013 microchip technology inc. cmstat (comparator status) ................................. 238 cmxcon (comparator x control) ............................ 237 corcon (cpu control) ........................................... 39 corcon (cpu core control) ................................... 90 ctmucon1h (ctmu control 1 high) .................... 246 ctmucon1l (ctmu control 1 low) ...................... 244 ctmucon2l (ctmu control 2 low) ...................... 248 cvrcon (comparator voltage reference control) ........................................... 240 dacxcon (dacx control) ...................................... 230 devid (device id) ................................................... 255 devrev (device revision) ..................................... 256 fbs (boot segment configuration) ......................... 249 fgs (general segment configuration) .................... 250 ficd (in-circuit debugger configuration) ................ 254 fosc (oscillator configuration) .............................. 251 foscsel (oscillator selection configuration) ........ 250 fpor (reset configuration) .................................... 253 fwdt (watchdog timer configuration) .................. 252 hlvdcon (high/low-voltage detect control) ........ 208 iec0 (interrupt enable control 0) .............................. 98 iec1 (interrupt enable control 1) .............................. 99 iec2 (interrupt enable control 2) ............................ 100 iec3 (interrupt enable control 3) ............................ 100 iec4 (interrupt enable control 4) ............................ 101 iec5 (interrupt enable control 5) ............................ 102 iec6 (interrupt enable control 6) ............................ 102 ifs0 (interrupt flag status 0) .................................... 93 ifs1 (interrupt flag status 1) .................................... 94 ifs2 (interrupt flag status 2) .................................... 95 ifs3 (interrupt flag status 3) .................................... 95 ifs4 (interrupt flag status 4) .................................... 96 ifs5 (interrupt flag status 5) .................................... 97 ifs6 (interrupt flag status 6) .................................... 97 intcon1 (interrupt control 1) ................................... 91 intcon2 (interrupt control 2) ................................... 92 inttreg (interrupt control and status) .................. 118 ipc0 (interrupt priority control 0) ............................ 103 ipc1 (interrupt priority control 1) ............................ 104 ipc10 (interrupt priority control 10) ........................ 111 ipc12 (interrupt priority control 12) ........................ 112 ipc15 (interrupt priority control 15) ........................ 113 ipc16 (interrupt priority control 16) ........................ 114 ipc18 (interrupt priority control 18) ........................ 115 ipc19 (interrupt priority control 19) ........................ 116 ipc2 (interrupt priority control 2) ............................ 105 ipc20 (interrupt priority control 20) ........................ 117 ipc24 (interrupt priority control 24) ........................ 117 ipc3 (interrupt priority control 3) ............................ 106 ipc4 (interrupt priority control 4) ............................ 107 ipc5 (interrupt priority control 5) ............................ 108 ipc6 (interrupt priority control 6) ............................ 109 ipc7 (interrupt priority control 7) ............................ 110 minsec (rtcc minutes and seconds value) ........ 188 mthdy (rtcc month and day value) ................... 187 nvmcon (flash memory control) ............................ 69 nvmcon (nonvolatile memory control) ................... 74 osccon (oscillator control) .................................. 123 osctun (frc oscillator tune) .............................. 126 padcfg1 (pad configuration control) ................... 171 rcfgcal (rtcc calibration and configuration) ........................................... 183 rcon (reset control) ............................................... 80 refocon (reference oscillator control) .............. 129 rtccswt (rtcc control/sample window timer) ............................................ .... 191 rtcpwc (rtcc configuration 2) .......................... 185 sr (alu status) .............................................. 38, 89 sspxadd (msspx slave address/baud rate generator) .............................................. . 170 sspxcon1 (msspx control 1, i 2 c mode) .............. 166 sspxcon1 (msspx control 1, spi mode) ............. 165 sspxcon2 (msspx control 2, i 2 c mode) .............. 167 sspxcon3 (msspx control 3, i 2 c mode) .............. 169 sspxcon3 (msspx control 3, spi mode) ............. 168 sspxmsk (i 2 c slave address mask) ...................... 170 sspxstat (msspx status, i 2 c mode) ................... 163 sspxstat (msspx status, spi mode) .................. 162 t1con (timer1 control) ......................................... 142 ulpwcon (ulpwu control) ................................. 133 uxmode (uartx mode) ......................................... 176 uxrxreg (uartx receive) ................................... 180 uxsta (uartx status and control) ........................ 178 uxtxreg (uartx transmit) .................................. 180 wkdyhr (rtcc weekday and hours value) ........ 188 year (rtcc year value) ....................................... 187 resets brown-out reset (bor) ............................................. 83 clock source selection .............................................. 82 delay times ............................................................... 82 device times ............................................................. 82 low-power bor (lpbor) ........................................ 83 rcon flag operation ............................................... 81 sfr states ................................................................ 83 retention regulator (retreg) ...................................... 134 revision history ............................................................... 325 rtcc alarm configuration ................................................. 192 alarm mask settings (figure) ................................... 193 alrmval register mappings ................................. 189 calibration ............................................................... 192 module registers ..................................................... 1 82 mapping ........................................................... 182 clock source selection ........................... 182 write lock ........................................................ 182 power control .......................................................... 193 rtcval register mappings .................................... 187 source clock ........................................................... 181 s serial peripheral interface. see spi mode. sfr space ........................................................................ 4 4 software stack ................................................................... 63 spi mode i/o pin configuration ............................................... 159 downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 331 pic24fv16km204 family t timer1 .............................................................................. 141 timing diagrams a/d conversion ........................................................ 295 brown-out reset characteristics ............................. 284 capture/compare/pwm (mccpx, sccpx) ............. 285 clko and i/o timing ......................................... ...... 282 example spi master mode (cke = 0) ..................... 286 example spi master mode (cke = 1) ..................... 287 example spi slave mode (cke = 0) ....................... 288 example spi slave mode (cke = 1) ....................... 289 external clock .......................................................... 280 i 2 c bus data ............................................................ 290 i 2 c bus start/stop bits ............................................. 290 msspx i 2 c bus data ............................................... 293 msspx i 2 c bus start/stop bits ................................ 292 reset, watchdog timer. oscillator start-up timer, power-up timer characteristics ...................... 283 timing requirements capture/compare/pwm (mccpx, sccpx) ............. 285 comparator .............................................................. 285 comparator voltage reference settling time ......... 285 i 2 c bus data (slave mode) ...................................... 291 i 2 c bus data requirements (master mode) ............ 293 i 2 c bus start/stop bits (master mode) .................... 292 i 2 c bus start/stop bits (slave mode) ...................... 290 spi mode (master mode, cke = 0) ......................... 286 spi mode (master mode, cke = 1) ......................... 287 spi mode (slave mode, cke = 0) ........................... 288 spi slave mode (cke = 1) ...................................... 289 u uart baud rate generator (brg) ................................... 174 break and sync transmit sequence ....................... 175 irda support ............................................... ............. 175 operation of uxcts and uxrts control pins ........ 175 receiving in 8-bit or 9-bit data mode ..................... 175 transmitting in 8-bit data mode .............................. 175 transmitting in 9-bit data mode .............................. 175 universal asynchronous receiver transmitter (uart) ................................................. 173 v voltage regulator (vreg) .............................................. 134 voltage-frequency graph (pic24f16km204 extended) .................................. 267 voltage-frequency graph (pic24f16km204 industrial) ................................... 266 voltage-frequency graph (pic24fv16km204 extended) ................................ 267 voltage-frequency graph (pic24fv16km204 industrial) ................................. 266 w watchdog timer (wdt) ......................................... .......... 257 windowed operation ............................................. .. 258 www address ................................................................ 332 www, on-line support ...... .............................................. 11 downloaded from: http:///
pic24fv16km204 family ds30003030b-page 332 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 333 pic24fv16km204 family the microchip web site microchip provides online support via our www site at www.microchip.com . this web site is used as a means to make files and information easily available to customers. accessible by using your favorite internet browser, the web site contains the following information: product support C data sheets and errata, application notes and sample programs, design resources, users guides and hardware support documents, latest software releases and archived software general technical support C frequently asked questions (faq), technical support requests, online discussion groups, microchip consultant program member listing business of microchip C product selector and ordering guides, latest microchip press releases, listing of seminars and events, listings of microchip sales offices, distributors and factory representatives customer change notification service microchips customer notification service helps keep customers current on microchip products. subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest. to register, access the microchip web site at www.microchip.com . under support, click on customer change notification and follow the registration instructions. customer support users of microchip products can receive assistance through several channels: distributor or representative local sales office field application engineer (fae) technical support customers should contact their distributor, representative or field application engineer (fae) for support. local sales offices are also available to help customers. a listing of sales offices and locations is included in the back of this document. technical support is available through the web site at: http://microchip.com/support downloaded from: http:///
pic24fv16km204 family ds30003030b-page 334 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 335 pic24fv16km204 family product identification system to order or obtain information, e. g., on pricing or delivery, refer to the factory or the listed sales office . architecture 24 = 16-bit modified harvard without dsp flash memory family f = standard voltage range flash program memory fv = wide voltage range flash program memory product group km2 = general purpose pic24f lite microcontroller km1 = general purpose pic24f lite microcontroller with reduced feature set pin count 01 = 20-pin 02 = 28-pin 04 = 44-pin temperature range i = -40 ? c to +85 ? c (industrial) e= -40 ? c to +125 ? c (extended) package sp = spdip so = soic ss = ssop ml = qfn p=pdip pt = tqfp mv = uqfn pattern three-digit qtp, sqtp, code or special requirements (blank otherwise) es = engineering sample examples: a) pic24fv16km204-i/ml: wide voltage range, general purpose, 16-kbyte program memory, 44-pin, industrial temp., qfn package b) pic24f08km102-i/ss: standard voltage range, general purpose with reduced feature set, 8-kbyte program memory, 28-pin, industrial temp., ssop package microchip trademark architecture flash memory family program memory size (kbytes) product group pin count temperature range package pattern pic 24 f v 16 km2 04 t - i / pt - xxx tape and reel flag (if applicable) downloaded from: http:///
pic24fv16km204 family ds30003030b-page 336 ? 2013 microchip technology inc. notes: downloaded from: http:///
? 2013 microchip technology inc. ds30003030b-page 337 information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, dspic, flashflex, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, pic 32 logo, rfpic, sst, sst logo, superflash and uni/o are registered trademarks of microchip technology incorporated in the u.s.a. and other countries. filterlab, hampshire, hi-tech c, linear active thermistor, mtp, seeval and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. silicon storage technology is a registered trademark of microchip technology inc. in other countries. analog-for-the-digital age, app lication maestro, bodycom, chipkit, chipkit logo, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, hi-tide, in-circuit serial programming, icsp, mindi, miwi, mpasm, mpf, mplab certified logo, mplib, mplink, mtouch, omniscient code generation, picc, picc-18, picdem, picdem.net, pickit, pictail, real ice, rflab, select mode, sqi, serial quad i/o, total endurance, tsharc, uniwindriver, wiperlock, zena and z-scale are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. gestic and ulpp are registered trademarks of microchip technology germany ii gmbh & co. kg, a subsidiary of microchip technology inc., in other countries. all other trademarks mentioned herein are property of their respective companies. ? 2013, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. isbn: 978-1-62077-358-1 note the following details of the code protection feature on microchip devices: microchip products meet the specification contai ned in their particular microchip data sheet. microchip believes that its family of products is one of the most secure families of its kind on the market today, when used i n the intended manner and under normal conditions. there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip products in a manner outside the operating specif ications contained in microchips data sheets. most likely, the person doing so is engaged in theft of intellectual property. microchip is willing to work with the customer who is concerned about the integrity of their code. neither microchip nor any other semiconduc tor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as unbreakable. code protection is constantly evolving. we at microchip are co mmitted to continuously improvin g the code protection features of our products. attempts to break microchips code protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the companys quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory an d analog products. in addition, microchips quality system for the design and manufacture of development systems is iso 9001:2000 certified. quality management s ystem certified by dnv == iso/ts 16949 == downloaded from: http:///
ds30003030b-page 338 ? 2013 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://www.microchip.com/ support web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 cleveland independence, oh tel: 216-447-0464 fax: 216-447-0643 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 indianapolis noblesville, in tel: 317-773-8323 fax: 317-773-5453 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8569-7000 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - chongqing tel: 86-23-8980-9588 fax: 86-23-8980-9500 china - hangzhou tel: 86-571-2819-3187 fax: 86-571-2819-3189 china - hong kong sar tel: 852-2943-5100 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8864-2200 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-3090-4444 fax: 91-80-3090-4123 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - osaka tel: 81-6-6152-7160 fax: 81-6-6152-9310 japan - tokyo tel: 81-3-6880- 3770 fax: 81-3-6880-3771 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-5778-366 fax: 886-3-5770-955 taiwan - kaohsiung tel: 886-7-213-7828 fax: 886-7-330-9305 taiwan - taipei tel: 886-2-2508-8600 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 worldwide sales and service 11/29/12 downloaded from: http:///


▲Up To Search▲   

 
Price & Availability of PIC24F08KM102-ISO

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X